package com.bbx.taxi.client.widget.SlidingCard2;

import java.text.NumberFormat;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import org.json.JSONException;
import org.json.JSONObject;

import butterknife.Bind;
import android.view.View.OnClickListener;
import android.view.View.OnTouchListener;

import com.bbx.androidapi.util.ToastUtil;
import com.bbx.api.gclient.GMsg;
import com.bbx.api.sdk.model.passanger.OrderDetailBuild;
import com.bbx.api.sdk.model.passanger.OrderEvaluate;
import com.bbx.api.sdk.model.passanger.Return.OrderDetails;
import com.bbx.api.sdk.model.passanger.Return.PriceDetail;
import com.bbx.api.sdk.model.passanger.Return.ShareDetail;
import com.bbx.api.sdk.model.passanger.Return.UsableSale;
import com.bbx.api.sdk.model.passanger.Return.CarType.CarType;
import com.bbx.api.sdk.model.passanger.Return.Jmsg.Msgs;
import com.bbx.api.sdk.model.passanger.Return.MyOrderList.MyOrderList;
import com.bbx.api.sdk.net.base.JsonBuild;
import com.bbx.api.sdk.net.passeger.conn.OrderDetailNet;
import com.bbx.api.sdk.net.passeger.conn.OrderEvaluateNet;
import com.bbx.taxi.client.Task.BaseAsyncTask;
import com.bbx.taxi.client.MyApplication;
import com.bbx.taxi.client.R;
import com.bbx.taxi.client.Activity.Main.MainActivity;
import com.bbx.taxi.client.Activity.Order.OrderEvaluationActivity2;
import com.bbx.taxi.client.Activity.Order.StartServiceActivity;
import com.bbx.taxi.client.Adapter.PayAdapter;
import com.bbx.taxi.client.Adapter.PayAdapter.ViewHolder;
import com.bbx.taxi.client.Adapter.PayDetailsAdapter;
import com.bbx.taxi.client.Bean.Value;
import com.bbx.taxi.client.Bean.Attribute.MainAttribute;
import com.bbx.taxi.client.Bean.Attribute.MainAttribute.CjType;
import com.bbx.taxi.client.Bean.Extra.MainMsg;
import com.bbx.taxi.client.DB.MyOrder.MyOrderDB;
import com.bbx.taxi.client.DB.MyOrder.MyOrderingDB;
import com.bbx.taxi.client.Task.MyOrderPayTask;
import com.bbx.taxi.client.Util.AgainOrder;
import com.bbx.taxi.client.Util.CouponUtils;
import com.bbx.taxi.client.Util.DateFormat;
import com.bbx.taxi.client.Util.FormatUtil;
import com.bbx.taxi.client.Util.ListViewHeight;
import com.bbx.taxi.client.Util.RequestUtils;
import com.bbx.taxi.client.Util.VersionUtils;
import com.bbx.taxi.client.emoji.MyConvertToMsg;
import com.bbx.taxi.client.pay.alipay.PayAlipay;
import com.bbx.taxi.client.pay.line.PayLine;
import com.bbx.taxi.client.pay.line.PayLine.OnLinePayFinishListener;
import com.bbx.taxi.client.pay.weixin.PayWeixin;
import com.bbx.taxi.client.widget.MaxByteLengthEditText;
import com.bbx.taxi.client.widget.Dailog.MyCouponDailog;
import com.bbx.taxi.client.widget.Dailog.MyCouponDailog.onClickLeftListener;
import com.bbx.taxi.client.widget.Dailog.MyCouponDailog.onClickRightListener;
import com.bbx.taxi.client.widget.Drag.DragLayout;
import com.bbx.taxi.client.widget.pop.SharePopView;
import com.bbx.taxi.client.widget.pop.SharePopView.OnShareDetaiFinish;
import com.bbx.taxi.client.wxapi.WXPayEntryActivity;

import android.app.Activity;
import android.content.Context;
import android.content.Intent;
import android.content.res.TypedArray;
import android.graphics.Bitmap;
import android.graphics.Canvas;
import android.graphics.Color;
import android.graphics.Paint;
import android.graphics.Rect;
import android.graphics.drawable.Drawable;
import android.net.Uri;
import android.os.AsyncTask;
import android.os.Build;
import android.os.Handler;
import android.os.Message;
import android.support.v4.view.KeyEventCompat;
import android.support.v4.view.MotionEventCompat;
import android.support.v4.view.VelocityTrackerCompat;
import android.support.v4.view.ViewCompat;
import android.support.v4.view.ViewConfigurationCompat;
import android.util.AttributeSet;
import android.util.FloatMath;
import android.util.Log;
import android.view.FocusFinder;
import android.view.Gravity;
import android.view.KeyEvent;
import android.view.LayoutInflater;
import android.view.MotionEvent;
import android.view.SoundEffectConstants;
import android.view.VelocityTracker;
import android.view.View;
import android.view.ViewConfiguration;
import android.view.ViewGroup;
import android.view.ViewParent;
import android.view.View.OnFocusChangeListener;
import android.view.animation.Interpolator;
import android.widget.AdapterView;
import android.widget.Button;
import android.widget.EditText;
import android.widget.FrameLayout;
import android.widget.ImageButton;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.ListView;
import android.widget.RatingBar;
import android.widget.RelativeLayout;
import android.widget.ScrollView;
import android.widget.Scroller;
import android.widget.TextView;
import android.widget.AdapterView.OnItemClickListener;
import android.widget.TextView.OnEditorActionListener;

/**
 */
public class SlidingCard extends LinearLayout implements OnClickListener
		 {
	/** 待评价状态 */
	public static final int STATUS_EVA = 0;
	/** 正在评价状态 */
	public static final int STATUS_EVAING = 1;
	/** 完成状态 */
	public static final int STATUS_FINISH = 2;
	/** 支付状态 */
	public static final int STATUS_PAY = 3;
	/** 界面状态，最下面的那个页面的，主要用于传递到卡片上去。卡片根据状态显示样本。评价状态，0待评价，1正在评价，2已评价 ,3待支付 */
	public int ym_status = STATUS_PAY;
	/** 判断订单信息是否有加载成功 */
	public boolean isSuccess = false;

	private static final String TAG = "SlidingCard";

	private static final boolean DEBUG = false;

	private static final boolean USE_CACHE = true;

	public static final int SLIDINGMODE_LEFT = 0;

	public static final int SLIDINGMODE_RIGHT = 1;

	public static final int SLIDINGMODE_LEFT_RIGHT = 2;

	public static final int TOUCHMODE_NONE = 0;

	public static final int TOUCHMODE_MARGIN = 1;

	public static final int TOUCHMODE_FULLSCREEN = 2;

	public static final int TOUCHMODE_BOUND = 3;

	private static final int MARGIN_THRESHOLD = 48; // dips

	private int mMarginThreshold;

	public static final int MAX_SETTLE_DURATION = 600; // ms

	private static final int MIN_DISTANCE_FOR_FLING = 25; // dips

	private int viewId;

	public static final Interpolator sInterpolator = new Interpolator() {
		public float getInterpolation(float t) {
			t -= 1.0f;
			return t * t * t * t * t + 1.0f;
		}
	};

	private boolean mEnabled = true;

	private List<View> mIgnoredViews = new ArrayList<View>();

	private int mSlidingMode;

	private int mTouchMode;

	private Drawable mLeftShadowDrawable;

	private int mLeftShadowWidth;

	private Drawable mRightShadowDrawable;

	private int mRightShadowWidth;

	private boolean mLeftFadeEnabled;

	private float mLeftFadeDegree;

	private boolean mRightFadeEnabled;

	private float mRightFadeDegree;

	private final Paint mLeftFadePaint = new Paint();

	private final Paint mRightFadePaint = new Paint();

	private final Paint mStackPaint = new Paint();

	private int mBehindStackCount = 0;

	private View mContent;

	private int mPrevItem = DEFAULT_ITEM;

	private int mCurItem = DEFAULT_ITEM;

	private static final int DEFAULT_ITEM = 0;

	private boolean mFirstLayout = true;

	private Scroller mScroller;

	private boolean mScrollingCacheEnabled;

	private boolean mScrolling;

	private boolean mIsBeingDragged;

	private boolean mIsUnableToDrag;

	private int mTouchSlop;

	private float mInitialMotionX;

	// variables for drawing
	private float mScrollX = 0.0f;

	/**
	 * Position of the last motion event.
	 */
	private float mLastMotionX;

	private float mLastMotionY;

	/**
	 * ID of the active pointer. This is used to retain consistency during
	 * drags/flings if multiple pointers are used.
	 */
	protected int mActivePointerId = INVALID_POINTER;

	/**
	 * Sentinel value for no current active pointer. Used by
	 * {@link #mActivePointerId}.
	 */
	private static final int INVALID_POINTER = -1;

	/**
	 * Determines speed during touch scrolling
	 */
	protected VelocityTracker mVelocityTracker;

	private int mMinimumVelocity;

	protected int mMaximumVelocity;

	private int mFlingDistance;

	private OnPageChangeListener mOnPageChangeListener;

	private int listIndex;

	private ImageView headShadyImageView;

	private Activity context;
	/** 司机名称 */
	public TextView tv_drivername;
	/** 车牌号 */
	public TextView tv_car_no;
	// /** 时间 */
	// public TextView tv_time;
	// /** 订单类型 */
	// public TextView tv_order_type;
	// /** 人数 */
	// public TextView tv_count;
	// /** 出发地 */
	// public TextView tv_start;
	// /** 目的地 */
	// public TextView tv_end;
	private TextView tv_cost_detail;
	/** 需支付金额 */
	private TextView tv_pay;
	/** 再次下单 */
	public RelativeLayout btn_confirm;
	public LinearLayout layout_confirm;
	/** 再次下单TextView */
	public TextView tv_confirm;
	public TextView tv_rating;
	public RatingBar rb_rating_b;
	/** 评价 */
	public RatingBar rb_rating_s;
	/** 提示语 ,匿名评价 */
	public RelativeLayout layout_anonymous;
	/** 支付列表 */
	private ListView listview_pay;
	/** 支付的费用明细列表 */
	private ListView listview_paydetail;
	/** 费用布局 */
	private LinearLayout layout_cost;
	/** 待评价布局 */
	private LinearLayout layout_evaluate;
	/** 费用明细的具体内容，该布局替换成另外一个视图出行，暂不可用 */
	private LinearLayout layout_cost_detail;
	/** 显示需支付和已支付 */
	TextView tv_need_pay;
	/** 支付方式标题 */
	RelativeLayout layout_payway;
	/** 我要优惠劵 */
	Button btn_coupon;
	/**司机电话*/
	ImageButton ib_sj;
	TextView text_offline_payment;
	public MaxByteLengthEditText et_message;
	public TextView et_message2;
	/** hint支付类型 */
	RelativeLayout layout_hint_paytype;
	TextView tv_hint_paytype;
	private OrderEvaluationActivity2 mOrderEvaluationActivity2;
	public String order_id;

	/** 支付列表 */
	private List<Map<String, String>> list;

	/** 支付费用明细列表 */
	private List<Map<String, String>> list_paydetail = new ArrayList<Map<String, String>>();
	/** 支付费用明细列表【更加详细，及另外一个界面】 */
	private List<Map<String, String>> list_paydetail_more = new ArrayList<Map<String, String>>();

	private PayAdapter mPayAdapter;

	private PayDetailsAdapter mPayDetailsAdapter;

	// 支付id,则为类型，0为银联
	private int pay_id = 0;
	/** 车费总计 */
	private double total_fare;
	/** 车费 */
	private double fare;
	/** 优惠劵 */
	private double coupon;
	/** 需要支付 */
	private double pay;
	/** 第三方支付优惠 */
	private double discount;

	private View contentView;

	private MyApplication mApplication;

	private MyOrderList mMyOrderList;
	private MyOrderDB db_myorder;
	private boolean isTouch = true;

	private String pay_gate;
	boolean isPaySuccuss=false;

	private OrderEvaluateTask mOrderEvaluateTask;
	private OrderDetailTask mOrderDetailTask;
	int down_y = 0;
	public int getListIndex() {
		return listIndex;
	}

	public void setListIndex(int listIndex) {
		this.listIndex = listIndex;
	}

	public void setOnPageChangeListener(OnPageChangeListener listener) {
		mOnPageChangeListener = listener;
	}

	/**
	 * Indicates that the pager is in an idle, settled state. The current page
	 * is fully in view and no animation is in progress.
	 */
	public static final int SCROLL_STATE_IDLE = 0;

	/**
	 * Indicates that the pager is currently being dragged by the user.
	 */
	public static final int SCROLL_STATE_DRAGGING = 1;

	/**
	 * Indicates that the pager is in the process of settling to a final
	 * position.
	 */
	public static final int SCROLL_STATE_SETTLING = 2;

	private int mScrollState = SCROLL_STATE_IDLE;

	/**
	 * Callback interface for responding to changing state of the selected page.
	 */
	public interface OnPageChangeListener {

		/**
		 * This method will be invoked when the current page is scrolled, either
		 * as part of a programmatically initiated smooth scroll or a user
		 * initiated touch scroll.
		 * 
		 * @param position
		 *            Position index of the first page currently being
		 *            displayed. Page position+1 will be visible if
		 *            positionOffset is nonzero.
		 * @param positionOffset
		 *            Value from [0, 1) indicating the offset from the page at
		 *            position.
		 * @param positionOffsetPixels
		 *            Value in pixels indicating the offset from position.
		 */
		public void onPageScrolled(SlidingCard v, int position,
				float positionOffset, int positionOffsetPixels);

		/**
		 * This method will be invoked when a new page becomes selected.
		 * Animation is not necessarily complete.
		 * 
		 * @param
		 *
		 */
		public void onPageSelected(SlidingCard v, int prevPosition,
				int curPosition);

		/**
		 * This method will be invoked when a new page becomes selected. after
		 * animation has completed.
		 * 
		 * @param
		 *
		 */
		public void onPageSelectedAfterAnimation(SlidingCard v,
				int prevPosition, int curPosition);

		/**
		 * Called when the scroll state changes. Useful for discovering when the
		 * user begins dragging, when the pager is automatically settling to the
		 * current page, or when it is fully stopped/idle.
		 * 
		 * @param state
		 *            The new scroll state.
		 * @see SlidingCard#SCROLL_STATE_IDLE
		 * @see SlidingCard#SCROLL_STATE_DRAGGING
		 * @see SlidingCard#SCROLL_STATE_SETTLING
		 */
		public void onPageScrollStateChanged(SlidingCard v, int state);

	}

	/**
	 * Simple implementation of the {@link OnPageChangeListener} interface with
	 * stub implementations of each method. Extend this if you do not intend to
	 * override every method of {@link OnPageChangeListener}.
	 */
	public static class SimpleOnPageChangeListener implements
			OnPageChangeListener {

		public void onPageScrolled(SlidingCard v, int position,
				float positionOffset, int positionOffsetPixels) {
			// This space for rent
		}

		public void onPageSelected(SlidingCard v, int prevPosition,
				int curPosition) {
			// This space for rent
		}

		@Override
		public void onPageSelectedAfterAnimation(SlidingCard v,
				int prevPosition, int curPosition) {
			// This space for rent
		}

		public void onPageScrollStateChanged(SlidingCard v, int state) {
			// This space for rent
		}

	}

	public SlidingCard(Activity context) {
		this(context, null);
		this.context = context;
	}

	public SlidingCard(Context context, AttributeSet attrs) {
		super(context, attrs);
		initSlidingCard();

		TypedArray ta = context.obtainStyledAttributes(attrs,
				R.styleable.SlidingCard);
		int slidingMode = ta.getInt(R.styleable.SlidingCard_sc_slidingMode,
				SLIDINGMODE_LEFT_RIGHT);
		setSlidingMode(slidingMode);
		int touchMode = ta.getInt(R.styleable.SlidingCard_sc_touchMode,
				TOUCHMODE_FULLSCREEN);
		setTouchMode(touchMode);
		int viewContent = ta.getResourceId(
				R.styleable.SlidingCard_sc_viewContent, -1);
		if (viewContent != -1) {
			setContent(viewContent);
		} else {
			setContent(new FrameLayout(context));
		}
		int leftShadowRes = ta.getResourceId(
				R.styleable.SlidingCard_sc_leftShadowDrawable, -1);
		if (leftShadowRes != -1) {
			setLeftShadowDrawable(leftShadowRes);
		}
		int leftShadowWidth = (int) ta.getDimension(
				R.styleable.SlidingCard_sc_leftShadowWidth, -1);
		if (leftShadowWidth != -1) {
			setLeftShadowWidth(leftShadowWidth);
		}
		int rightShadowRes = ta.getResourceId(
				R.styleable.SlidingCard_sc_rightShadowDrawable, -1);
		if (rightShadowRes != -1) {
			setRightShadowDrawable(rightShadowRes);
		}
		int rightShadowWidth = (int) ta.getDimension(
				R.styleable.SlidingCard_sc_rightShadowWidth, -1);
		if (rightShadowWidth > -1) {
			setRightShadowWidth(rightShadowWidth);
		}
		boolean leftFadeEnabled = ta.getBoolean(
				R.styleable.SlidingCard_sc_leftFadeEnabled, true);
		setLeftFadeEnabled(leftFadeEnabled);
		float leftFadeDeg = ta.getFloat(
				R.styleable.SlidingCard_sc_leftFadeDegree, 0.5f);
		setLeftFadeDegree(leftFadeDeg);
		boolean rightFadeEnabled = ta.getBoolean(
				R.styleable.SlidingCard_sc_rightFadeEnabled, true);
		setRightFadeEnabled(rightFadeEnabled);
		float rightFadeDeg = ta.getFloat(
				R.styleable.SlidingCard_sc_rightFadeDegree, 0.33f);
		setRightFadeDegree(rightFadeDeg);
		ta.recycle();
	}

	void initSlidingCard() {
		setWillNotDraw(false);
		setDescendantFocusability(FOCUS_AFTER_DESCENDANTS);
		setFocusable(true);
		final Context context = getContext();
		mScroller = new Scroller(context, sInterpolator);
		final ViewConfiguration configuration = ViewConfiguration.get(context);
		mTouchSlop = ViewConfigurationCompat
				.getScaledPagingTouchSlop(configuration);
		mMinimumVelocity = configuration.getScaledMinimumFlingVelocity();
		mMaximumVelocity = configuration.getScaledMaximumFlingVelocity();
		final float density = context.getResources().getDisplayMetrics().density;
		mFlingDistance = (int) (MIN_DISTANCE_FOR_FLING * density);

		mMarginThreshold = (int) (MARGIN_THRESHOLD * density);
	}

	@Override
	protected void onAttachedToWindow() {
		super.onAttachedToWindow();
		mFirstLayout = true;
	}

	@Override
	protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
		// int itemHeight = getContext().getResources().getDimensionPixelSize(
		// R.dimen.card_item_height);
		// int width = getDefaultSize(0, widthMeasureSpec);
		// int height = getDefaultSize(0, heightMeasureSpec);
		// setMeasuredDimension(width, itemHeight);
		// final int contentWidth = getChildMeasureSpec(widthMeasureSpec, 0,
		// width);
		// final int contentHeight = getChildMeasureSpec(heightMeasureSpec, 0,
		// height);
		// mContent.measure(contentWidth, itemHeight);
		super.onMeasure(widthMeasureSpec, heightMeasureSpec);
	}

	@Override
	protected void onSizeChanged(int w, int h, int oldw, int oldh) {
		super.onSizeChanged(w, h, oldw, oldh);
		if (w != oldw) {
			completeScroll();
			scrollTo(getDestScrollX(mCurItem), getScrollY());
		}
	}

	@Override
	protected void onLayout(boolean changed, int l, int t, int r, int b) {
		final int width = r - l;
		final int height = b - t;
		mContent.layout(0, 0, width, height);

		if (mFirstLayout) {
			scrollTo(getDestScrollX(mCurItem), getScrollY());
		}
		mFirstLayout = false;
	}

	@Override
	public void computeScroll() {
		if (!mScroller.isFinished()) {
			if (mScroller.computeScrollOffset()) {
				int oldX = getScrollX();
				int oldY = getScrollY();
				int x = mScroller.getCurrX();
				int y = mScroller.getCurrY();

				if (oldX != x || oldY != y) {
					scrollTo(x, y);
					pageScrolled(x);
				} else {
					setScrollState(SCROLL_STATE_IDLE);
				}

				// Keep on drawing until the animation has finished.
				ViewCompat.postInvalidateOnAnimation(this);
				return;
			}
		}

		// Done with scroll, clean up state.
		completeScroll();
	}

	@Override
	public void scrollTo(int x, int y) {
		super.scrollTo(x, y);
		mScrollX = x;
	}

	private void pageScrolled(int xpos) {
		final int widthWithMargin = getWidth();
		final int position = xpos / widthWithMargin;
		final int offsetPixels = xpos % widthWithMargin;
		final float offset = (float) offsetPixels / widthWithMargin;

		if (mOnPageChangeListener != null) {
			mOnPageChangeListener.onPageScrolled(this, position, offset,
					offsetPixels);
		}
	}

	private void setScrollState(int newState) {

		if (mScrollState == newState) {
			return;
		}

		mScrollState = newState;
		disableLayers();
		if (mOnPageChangeListener != null) {
			mOnPageChangeListener.onPageScrollStateChanged(this, newState);
		}
	}

	public int getScrollState() {
		return mScrollState;
	}

	private void completeScroll() {
		boolean needPopulate = mScrolling;
		if (needPopulate) {
			// Done with scroll, no longer want to cache view drawing.
			setScrollingCacheEnabled(false);
			mScroller.abortAnimation();
			int oldX = getScrollX();
			int oldY = getScrollY();
			int x = mScroller.getCurrX();
			int y = mScroller.getCurrY();
			if (oldX != x || oldY != y) {
				scrollTo(x, y);
			} else {
				setScrollState(SCROLL_STATE_IDLE);
			}
			if (mOnPageChangeListener != null && mPrevItem != mCurItem) {
				mOnPageChangeListener.onPageSelectedAfterAnimation(this,
						mPrevItem, mCurItem);
			}
		}
		mScrolling = false;
	}

	private void setScrollingCacheEnabled(boolean enabled) {
		if (mScrollingCacheEnabled != enabled) {
			mScrollingCacheEnabled = enabled;
			if (USE_CACHE) {
				final int size = getChildCount();
				for (int i = 0; i < size; ++i) {
					final View child = getChildAt(i);
					if (child.getVisibility() != GONE) {
						child.setDrawingCacheEnabled(enabled);
						if (enabled && isLowQuality) {
							child.setDrawingCacheBackgroundColor(Color.TRANSPARENT);
							child.setDrawingCacheQuality(DRAWING_CACHE_QUALITY_LOW);
						}
					}
				}
			}
		}
	}

	float distanceInfluenceForSnapDuration(float f) {
		f -= 0.5f; // center the values about 0.
		f *= 0.3f * Math.PI / 2.0f;
		return (float) Math.sin(f);
	}

	/**
	 * Like {@link View#scrollBy}, but scroll smoothly instead of immediately.
	 * 
	 * @param x
	 *            the number of pixels to scroll by on the X axis
	 * @param y
	 *            the number of pixels to scroll by on the Y axis
	 */
	void smoothScrollTo(int x, int y) {
		smoothScrollTo(x, y, 0);
	}

	/**
	 * Like {@link View#scrollBy}, but scroll smoothly instead of immediately.
	 * 
	 * @param x
	 *            the number of pixels to scroll by on the X axis
	 * @param y
	 *            the number of pixels to scroll by on the Y axis
	 * @param velocity
	 *            the velocity associated with a fling, if applicable. (0
	 *            otherwise)
	 */
	void smoothScrollTo(int x, int y, int velocity) {
		if (getChildCount() == 0) {
			// Nothing to do.
			setScrollingCacheEnabled(false);
			return;
		}
		int sx = getScrollX();
		int sy = getScrollY();
		int dx = x - sx;
		int dy = y - sy;
		if (dx == 0 && dy == 0) {
			completeScroll();
			setScrollState(SCROLL_STATE_IDLE);
			return;
		}

		setScrollingCacheEnabled(true);
		setScrollState(SCROLL_STATE_SETTLING);
		mScrolling = true;

		final int width = getWidth();
		final int halfWidth = width / 2;
		final float distanceRatio = Math.min(1f, 1.0f * Math.abs(dx) / width);
		final float distance = halfWidth + halfWidth
				* distanceInfluenceForSnapDuration(distanceRatio);

		int duration = 0;
		velocity = Math.abs(velocity);
		if (velocity > 0) {
			duration = 4 * Math.round(1000 * Math.abs(distance / velocity));
		} else {
			final float pageDelta = (float) Math.abs(dx) / width;
			duration = (int) ((pageDelta + 1) * 100);
			duration = MAX_SETTLE_DURATION;
		}
		duration = Math.min(duration, MAX_SETTLE_DURATION);

		mScroller.startScroll(sx, sy, dx, dy, duration);
		invalidate();
	}

	void scrollToPx(int x, int y) {
		int sx = getScrollX();
		int sy = getScrollY();
		int dx = x - sx;
		int dy = y - sy;
		scrollTo(x, y);
		invalidate();
	}

	void setCurrentItemInternal(int item, boolean smoothScroll, boolean always) {
		setCurrentItemInternal(item, smoothScroll, always, 0);
	}

	void setCurrentItemInternal(int item, boolean smoothScroll, boolean always,
			int velocity) {
		if (!always && mCurItem == item) {
			setScrollingCacheEnabled(false);
			return;
		}

		item = getTargetPage(item);

		final boolean dispatchSelected = mCurItem != item;
		mPrevItem = mCurItem;
		mCurItem = item;
		final int destX = getDestScrollX(mCurItem);
		if (dispatchSelected && mOnPageChangeListener != null) {
			mOnPageChangeListener.onPageSelected(this, mPrevItem, mCurItem);
		}
		if (smoothScroll) {
			smoothScrollTo(destX, 0, velocity);
		} else {
			completeScroll();
			scrollTo(destX, 0);
			if (mOnPageChangeListener != null && mPrevItem != mCurItem) {
				mOnPageChangeListener.onPageSelectedAfterAnimation(this,
						mPrevItem, mCurItem);
			}
		}
	}

	int getTargetPage(int page) {
		if (mTouchMode == TOUCHMODE_BOUND) {
			return 1;
		}
		page = (page > 1) ? 2 : ((page < 1) ? 0 : page);
		if (mSlidingMode == SLIDINGMODE_LEFT && page > 1) {
			return 0;
		} else if (mSlidingMode == SLIDINGMODE_RIGHT && page < 1) {
			return 2;
		} else {
			return page;
		}
	}

	int getDestScrollX(int page) {
		if (mSlidingMode == SLIDINGMODE_LEFT) {
			switch (page) {
			case 0:
				return mContent.getLeft() - getCardWidth();
			case 1:
			case 2:
				return mContent.getLeft();
			}
		} else if (mSlidingMode == SLIDINGMODE_RIGHT) {
			switch (page) {
			case 0:
			case 1:
				return mContent.getLeft();
			case 2:
				return mContent.getLeft() + getCardWidth();
			}
		} else if (mSlidingMode == SLIDINGMODE_LEFT_RIGHT) {
			switch (page) {
			case 0:
				return mContent.getLeft() - getCardWidth();
			case 1:
				return mContent.getLeft();
			case 2:
				return mContent.getLeft() + getCardWidth();
			}
		}
		return 0;
	}

	public void setDefaultItem(int defaultItem) {
		mCurItem = defaultItem;
	}

	public void resetItemAsDefault() {
		mPrevItem = DEFAULT_ITEM;
		mCurItem = DEFAULT_ITEM;
		setScrollingCacheEnabled(false);
		mScroller.abortAnimation();
		mScrollState = SCROLL_STATE_IDLE;
		final int destX = getDestScrollX(DEFAULT_ITEM);
		scrollTo(destX, 0);
		mScrolling = false;
		setVisibility(View.VISIBLE);
	}

	public void setCurrentItem(int item) {
		setCurrentItemInternal(item, true, false);
	}

	public void setCurrentItem(int item, boolean smoothScroll) {
		setCurrentItemInternal(item, smoothScroll, false);
	}

	public int getCurrentItem() {
		return mCurItem;
	}

	public void setSlidingMode(int mode) {
		if (mode != SLIDINGMODE_LEFT && mode != SLIDINGMODE_RIGHT
				&& mode != SLIDINGMODE_LEFT_RIGHT) {
			throw new IllegalStateException(
					"SlidingMode must be SLIDINGMODE_LEFT, SLIDINGMODE_RIGHT, or SLIDINGMODE_LEFT_RIGHT");
		}
		mSlidingMode = mode;
	}

	public int getSlidingMode() {
		return mSlidingMode;
	}

	public void setTouchMode(int mode) {
		if (mode != TOUCHMODE_FULLSCREEN && mode != TOUCHMODE_MARGIN
				&& mode != TOUCHMODE_NONE && mode != TOUCHMODE_BOUND) {
			throw new IllegalStateException(
					"TouchMode must be set to either"
							+ "TOUCHMODE_FULLSCREEN or TOUCHMODE_MARGIN or TOUCHMODE_NONE.");
		}
		mTouchMode = mode;
	}

	public int getTouchMode() {
		return mTouchMode;
	}

	@Override
	public void addView(View child) {
		try {
			super.removeAllViews();
		} catch (Exception e) {
			Log.e("lq", String.valueOf(e.getMessage()));
		}
		mContent = child;
		super.addView(child);
		disableLayers();
	}

	@Override
	public void removeView(View view) {
		try {
			super.removeView(view);
		} catch (Exception e) {
			Log.e("lq", String.valueOf(e.getMessage()));
		}
		disableLayers();
	}

	public void setContent(int res) {
		setContent(LayoutInflater.from(getContext()).inflate(res, null));
	}

	public void setContent(View v) {
		addView(v);
	}

	/**
	 * 设置卡片内容
	 */
	public void initCardChildView() {
		mApplication = MyApplication.getInstance();
		tv_drivername = (TextView) findViewById(R.id.tv_drivername);
		tv_car_no = (TextView) findViewById(R.id.tv_car_no);
		// tv_time = (TextView) findViewById(R.id.tv_time);
		// tv_order_type = (TextView) findViewById(R.id.order_type);
		// tv_count = (TextView) findViewById(R.id.tv_count);
		// tv_start = (TextView) findViewById(R.id.tv_start);
		// tv_end = (TextView) findViewById(R.id.tv_end);
		tv_cost_detail = (TextView) findViewById(R.id.tv_cost_detail);
		tv_pay = (TextView) findViewById(R.id.tv_pay);
		btn_confirm = (RelativeLayout) findViewById(R.id.btn_confirm);
		layout_confirm= (LinearLayout) findViewById(R.id.layout_confirm);
		tv_confirm = (TextView) findViewById(R.id.tv_confirm);
		et_message = (MaxByteLengthEditText) findViewById(R.id.et_message);
		et_message.setOnEditorActionListener(new OnEditorActionListener() {
			@Override
			public boolean onEditorAction(TextView arg0, int arg1,
					KeyEvent event) {
				return (event.getKeyCode() == KeyEvent.KEYCODE_ENTER);
			}
		});
		et_message.setMaxByteLength(60);
		et_message.setOnClickListener(new OnClickListener() {

			@Override
			public void onClick(View arg0) {
				// TODO Auto-generated method stub

			}
		});
		et_message2 = (TextView) findViewById(R.id.et_message2);
		layout_anonymous = (RelativeLayout) findViewById(R.id.layout_anonymous);
		headShadyImageView = (ImageView) findViewById(R.id.user_imageview_shady);
		contentView = findViewById(R.id.sliding_card_view);
		tv_rating = (TextView) findViewById(R.id.tv_rating);
		rb_rating_s = (RatingBar) findViewById(R.id.rb_rating_s);
		rb_rating_b = (RatingBar) findViewById(R.id.rb_rating_b);
		listview_pay = (ListView) findViewById(R.id.listview_pay);
		listview_paydetail = (ListView) findViewById(R.id.lv_paydetail);
		layout_cost = (LinearLayout) findViewById(R.id.include_cost);
		layout_evaluate = (LinearLayout) findViewById(R.id.layout_evaluate);
		layout_cost_detail = (LinearLayout) findViewById(R.id.layout_cost_detail);
		tv_need_pay = (TextView) findViewById(R.id.tv_need_pay);
		layout_payway = (RelativeLayout) findViewById(R.id.layout_payway);
		layout_hint_paytype = (RelativeLayout) findViewById(R.id.layout_hint_paytype);
		tv_hint_paytype = (TextView) findViewById(R.id.tv_hint_paytype);
		btn_coupon = (Button) findViewById(R.id.btn_coupon);
		btn_coupon.setOnClickListener(this);
		ib_sj=(ImageButton) findViewById(R.id.ib_sj);
		text_offline_payment=(TextView) findViewById(R.id.text_offline_payment);
		ib_sj.setOnClickListener(this);
		layout_evaluate.setOnTouchListener(new OnTouchListener() {

			@Override
			public boolean onTouch(View v, MotionEvent event) {
				int move_y = 0;
				if (event.getAction() == MotionEvent.ACTION_DOWN) {
					down_y = (int) event.getY();
				}
				if (event.getAction() == MotionEvent.ACTION_UP) {
					move_y = (int) event.getY();
					if ((move_y - down_y) > 50) {
						if (getYMStatus() == STATUS_EVAING) {
							setYMStatus(STATUS_EVA);
						}
					}
				}
				return false;
			}
		});
		onSetPayList();
		mPayDetailsAdapter = new PayDetailsAdapter(context, list_paydetail);
		listview_paydetail.setAdapter(mPayDetailsAdapter);
		headShadyImageView.setAlpha(0);
		Drawable drawable = headShadyImageView.getBackground();
		if (drawable != null) {
			drawable.setAlpha(0);
		}
		db_myorder = new MyOrderDB();
		if (mMyOrderList == null) {//没有setMyOrderList进行赋值的话，就为空
			mMyOrderList = db_myorder.onReadDB(order_id);
		}
		if (mMyOrderList != null) {
			order_id = mMyOrderList.getOrder_id();
			tv_drivername.setText(mMyOrderList.getDriver_name());
			tv_car_no.setText(mMyOrderList.getCar_NO());
			// tv_time.setText(mMyOrderList.getAppoint_time());
			 MainAttribute main=MainAttribute.getInstance();
			final int order_type = mMyOrderList.getOrder_type();
			switch (order_type) {
			case Value.ORDER_TYPE_SN:
				// tv_order_type.setText(R.string.sn);
				viewId = Value.VIEWID_SN;
				// tv_count.setVisibility(View.GONE);
				// layout_money.setVisibility(View.GONE);
				break;
			case Value.ORDER_TYPE_KJ:
				// tv_order_type.setText(R.string.kj);
				viewId = Value.VIEWID_KJ;
				// tv_count.setText(String.format(context.getString(R.string.num_jian),
				// mMyOrderList.getLocations().getCount()));
				break;
			case Value.ORDER_TYPE_PC:
				// tv_order_type.setText(R.string.pc);
				viewId = Value.VIEWID_PC;
				main.setCjType(CjType.PC);
				// tv_count.setText(String.format(context.getString(R.string.num),
				// mMyOrderList.getLocations().getCount()));
				break;
			case Value.ORDER_TYPE_BC:
				// tv_order_type.setText(R.string.bc);
				viewId = Value.VIEWID_PC;
				main.setCjType(CjType.BC);
				// tv_count.setText(String.format(context.getString(R.string.num_car),
				// mMyOrderList.getLocations().getCount()));
				break;
			}

			// tv_start.setText(mMyOrderList.getLocations().getStart().getAddress());
			// tv_end.setText(mMyOrderList.getLocations().getEnd().getAddress());
			// 车费
			String str_fare = FormatUtil.onFormatPrice(mMyOrderList.getPrice());
			fare = Double.parseDouble(str_fare);
			// 费用详情
			PriceDetail price_detail = mMyOrderList.getPrice_Detail();
			discount = Double.parseDouble(list.get(pay_id).get(
					PayAdapter.DISCOUNT));
			if (price_detail != null) {
				// 需支付
				pay = Double.parseDouble(FormatUtil.onFormatPrice(price_detail
						.getTotal())) - discount;
				// 车费总计=需支付+第三方支付+优惠劵
				total_fare = pay + coupon + discount;
				coupon = price_detail.getDiscountAmt();

				list_paydetail.clear();
				// 添加车费总计
				addPayDetail(context.getString(R.string.total_fare),
						total_fare + "", PayDetailsAdapter.TYPE_PRICE,"",true);
				if (coupon != 0) {
					// 添加优惠劵
					addCouponPayDetail(true);
					mPayDetailsAdapter.notifyDataSetChanged();
					ListViewHeight.setListViewHeightBasedOnChildren(listview_paydetail);
				}
			} else {
				// 车费总计=车费
				total_fare = fare;
				pay = fare - discount;
			}
			tv_pay.setText(FormatUtil.onFormatDecimal(pay));
			if (getYMStatus() == STATUS_PAY) {
				tv_confirm.setText(String.format(
						context.getString(R.string.confirm_pay),
						tv_pay.getText()));
			}
			// ////////////////
			rb_rating_s.setRating(FormatUtil.onFormatStar((float) mMyOrderList
					.getDriver_star()));
			tv_rating.setText(FormatUtil.onFormatStar((float) mMyOrderList
					.getDriver_star()) + "");

			setYMStatus(ym_status);
			btn_confirm.setOnClickListener(new OnClickListener() {

				@Override
				public void onClick(View v) {
					if(tv_confirm.getText().toString().equals(context.getString(R.string.btn_confirmation))){
						getOrderDetail(order_id, true);	
					}else{
					// 提交评价
					if (getYMStatus() == STATUS_EVAING) {
						// 提交评价
						OrderEvaluate mOrderEvaluate = new OrderEvaluate(
								context);
						mOrderEvaluate.uid = mApplication.getUid();
						mOrderEvaluate.access_token = mApplication.getToken();
						mOrderEvaluate.order_id = mMyOrderList.getOrder_id();
						mOrderEvaluate.driver_id = mMyOrderList.getDriver_id();
						mOrderEvaluate.star = ((int) rb_rating_b.getRating()) * 20;
						mOrderEvaluate.suggest = new MyConvertToMsg()
								.parseEmoji(context, et_message.getText()
										.toString());
						mOrderEvaluate.problem = "";
						mOrderEvaluateTask = new OrderEvaluateTask(
								getContext(), mOrderEvaluate);
						mOrderEvaluateTask.executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
					} // 再次下单
						// 再次下单
					else if (getYMStatus() == STATUS_EVA
							|| getYMStatus() == STATUS_FINISH) {
						AgainOrder.onAgainOrder(getContext(), mMyOrderList, viewId);
					}
					// 支付
					else if (getYMStatus() == STATUS_PAY) {
						if (!getLoadSuccess()) {
							ToastUtil.showToast(context, R.string.no_network);
						} else {
							MyOrderPayTask.GATEWAY gateway = null;
							if (list.get(pay_id).get(PayAdapter.TYPE)
									.equals(PayAdapter.TYPE_YINLIAN)) {
							} else if (list.get(pay_id).get(PayAdapter.TYPE)
									.equals(PayAdapter.TYPE_ALIPAY)) {
								gateway=MyOrderPayTask.GATEWAY.alipay;
							} else if (list.get(pay_id).get(PayAdapter.TYPE)
									.equals(PayAdapter.TYPE_WEIXIN)) {
								gateway=MyOrderPayTask.GATEWAY.weixin;
							}else if (list.get(pay_id).get(PayAdapter.TYPE)
									.equals(PayAdapter.TYPE_LINE)) {
								gateway=MyOrderPayTask.GATEWAY.line;
							}else if (list.get(pay_id).get(PayAdapter.TYPE)
									.equals(PayAdapter.TYPE_YUE)) {
								gateway=MyOrderPayTask.GATEWAY.yue;
							}
							int int_pay=(int)(pay*100);
							RequestUtils.requesOrderPay(context, gateway, order_id, mMyOrderList.getDriver_id(), int_pay);
						}
					  }
					}
				}
			});
			rb_rating_b.setIsIndicator(true);
			rb_rating_b.setOnTouchListener(new OnTouchListener() {

				@Override
				public boolean onTouch(View v, MotionEvent event) {
					if (!isTouch)
						return true;
					switch (event.getAction()) {
					case MotionEvent.ACTION_DOWN:
						setYMStatus(STATUS_EVAING);
						break;
					}
					return false;
				}
			});
			// 点击费用明细
			tv_cost_detail.setOnClickListener(new OnClickListener() {

				@Override
				public void onClick(View arg0) {
					getOrderEvaluationActivity().dragLayout
							.setVisibility(View.VISIBLE);
					getOrderEvaluationActivity().dragLayout.open();
					getOrderEvaluationActivity().dragLayout.setTime(DateFormat
							.onDateRemove_ss(mMyOrderList.getAppoint_time()));
					switch (order_type) {
					case Value.ORDER_TYPE_SN:
						getOrderEvaluationActivity().dragLayout
								.setOrderType(context.getString(R.string.sn));
						getOrderEvaluationActivity().dragLayout
								.setCountVisibility(View.GONE);
						break;
					case Value.ORDER_TYPE_PC:
						getOrderEvaluationActivity().dragLayout
								.setOrderType(context.getString(R.string.pc));
						getOrderEvaluationActivity().dragLayout.setCount(String
								.format(context.getString(R.string.num),
										mMyOrderList.getLocations().getCount()));
						break;
					case Value.ORDER_TYPE_BC:
						getOrderEvaluationActivity().dragLayout
								.setOrderType(context.getString(R.string.bc));
						getOrderEvaluationActivity().dragLayout.setCount(String
								.format(context.getString(R.string.num_car),
										mMyOrderList.getLocations().getCount()));
						break;
					case Value.ORDER_TYPE_KJ:
						getOrderEvaluationActivity().dragLayout
								.setOrderType(context.getString(R.string.kj));
//						getOrderEvaluationActivity().dragLayout.setCount(String
//								.format(context.getString(R.string.num_jian),
//										mMyOrderList.getLocations().getCount()));
						break;
					}
					switch(mMyOrderList.getOrder_origin()){
					  case  Value.ORDER_ORIGIN://爱心直通车
						  getOrderEvaluationActivity().dragLayout.setOrderType(context.getString(R.string.aixin));
						  getOrderEvaluationActivity().dragLayout.setCountVisibility(View.GONE);
						  break;
					  case Value.ORDER_ORIGIN_SF://顺风
						  getOrderEvaluationActivity().dragLayout.setOrderType(context.getString(R.string.sf));
						  break;
					}
					getOrderEvaluationActivity().dragLayout
							.setStart(mMyOrderList.getLocations().getStart()
									.getAddress());
					getOrderEvaluationActivity().dragLayout.setEnd(mMyOrderList
							.getLocations().getEnd().getAddress());
					getOrderEvaluationActivity().dragLayout.setPay(pay,
							getYMStatus() != STATUS_PAY, pay_gate);
					try{
					// 更详细的费用明细。
					list_paydetail_more.clear();
					list_paydetail_more.clear();
					int calc_type=mMyOrderList.getCalcType();
					//倍率
					double base_discount=Double.parseDouble(mMyOrderList.getPrice_Detail().getBaseDiscount());
					//如果是计费，则显示套餐费
					if(calc_type==CarType.CALC_TYPE_jifei){		
						double combo_price=mMyOrderList.getPrice_Detail().getCombo_price();
						double mile_price=mMyOrderList.getPrice_Detail().getMile_price();
						double time_price=mMyOrderList.getPrice_Detail().getTime_price();
						// 套餐费
						try{
						if(combo_price!=0)
						addPayDetail_More(context.getString(R.string.price_combo),FormatUtil.onFormatPrice(combo_price),
								PayDetailsAdapter.TYPE_PRICE, "");
						}catch(Exception e){}
						// 超里程费
						try{
					    if(mile_price!=0)
						addPayDetail_More(context.getString(R.string.price_mile),FormatUtil.onFormatPrice(mile_price),
								PayDetailsAdapter.TYPE_PRICE, "");
						}catch(Exception e){}
						// 超时长费
						try{
						if(time_price!=0)
						addPayDetail_More(context.getString(R.string.price_time),FormatUtil.onFormatPrice(time_price),
								PayDetailsAdapter.TYPE_PRICE, "");
						}catch(Exception e){}
						
						//打折后的价格  ，转化为元 
						double totle=Double.parseDouble(FormatUtil.onFormatCeil((combo_price+mile_price+time_price)*(base_discount/100)));
						//原价  ，转化为元 
						double base_price=Double.parseDouble(FormatUtil.onFormatPrice(combo_price+mile_price+time_price));
						//调价N倍
						if(base_discount==100){
						}else{
						   String str_discount="";
						   if(base_discount>100)str_discount="加价"+(base_discount/100)+"倍";
						   else if(base_discount<100)str_discount="活动折扣"+(base_discount/10)+"折";
							
						  addPayDetail_More(str_discount, FormatUtil.onFormatDecimal(Math.abs(totle-base_price)),
								  base_discount>100?PayDetailsAdapter.TYPE_PRICE:PayDetailsAdapter.TYPE_REDUCE, "");
						}
					}
					//普通计价
					else{
						//原价，，转化为元
						double base_price=0;
						if ( mMyOrderList.getOrder_type() == Value.ORDER_TYPE_SN) {
							base_price=Double.parseDouble(FormatUtil.onFormatPrice(mMyOrderList.getPrice_Detail().getMetered_fee()));

						}else{
							if(base_discount==100){
								base_price=Double.parseDouble(FormatUtil.onFormatPrice(mMyOrderList.getPrice()));
							}else{
								base_price=Double.parseDouble(FormatUtil.onFormatPrice(mMyOrderList.getPrice_Detail().getBasePrice()));
							}
							
						}
						// 添加车费原价
						   addPayDetail_More(context.getString(R.string.fare), FormatUtil.onFormatDecimalCeil(base_price),
								 PayDetailsAdapter.TYPE_PRICE, "");
						//调价N倍
						if(base_discount==100){
						}else{
						   String str_discount="";
						   if(base_discount>100)str_discount="加价"+(base_discount/100)+"倍";
						   else if(base_discount<100)str_discount="活动折扣"+(base_discount/10)+"折";
							
						  //打折后的价格  ，base_price已经是元了，不需要转换
						  double totle=Double.parseDouble(FormatUtil.onFormatDecimalCeil(base_price*(base_discount/100)));
						  addPayDetail_More(str_discount,FormatUtil.onFormatDecimal(Math.abs(totle-base_price)),
								  base_discount>100?PayDetailsAdapter.TYPE_PRICE:PayDetailsAdapter.TYPE_REDUCE, "");
						}
					}
					// 添加高速费
					addPayDetail_More(context.getString(R.string.highwey_fee),
							((mMyOrderList.getPrice_Detail() == null) ?"0"
									: FormatUtil.onFormatPrice(mMyOrderList.getPrice_Detail().getHighwey_fee())),
							PayDetailsAdapter.TYPE_PRICE,"");
					// 行李费
					addPayDetail_More(context.getString(R.string.package_fee),
							((mMyOrderList.getPrice_Detail() == null) ? "0"
									:FormatUtil.onFormatPrice(mMyOrderList.getPrice_Detail().getPackage_fee())),
							PayDetailsAdapter.TYPE_PRICE,"");
					// 带小孩
					addPayDetail_More(context.getString(R.string.child_fee),
							((mMyOrderList.getPrice_Detail() == null) ?  "0"
									: FormatUtil.onFormatPrice(mMyOrderList.getPrice_Detail().getChild_fee())),
							PayDetailsAdapter.TYPE_PRICE,"");
					// 超距离
					addPayDetail_More(
							context.getString(R.string.over_distance),
							((mMyOrderList.getPrice_Detail() == null) ?  "0"
									: FormatUtil.onFormatPrice(mMyOrderList.getPrice_Detail().getOver_distance())),
							PayDetailsAdapter.TYPE_PRICE,"");
					int schedule_fee_id = 0;
					switch(VersionUtils.getVersionType(context)){
					case bbx:
						schedule_fee_id=R.string.schedule_fee;
						break;
					case tianshang:
						schedule_fee_id=R.string.schedule_fee2;
						break;
					}
					//调度费
					addPayDetail_More(
							context.getString(schedule_fee_id),
							((mMyOrderList.getPrice_Detail() == null) ? "0"
									: FormatUtil.onFormatPrice(mMyOrderList
											.getPrice_Detail().getSchedule_fee())),
							PayDetailsAdapter.TYPE_PRICE, "");
					// 添加优惠劵
					addPayDetail_More(context.getString(R.string.end_coupon),
							coupon+"", PayDetailsAdapter.TYPE_REDUCE,"");
					// 添加第三方折扣
					addPayDetail_More(list.get(pay_id).get(PayAdapter.TEXT)
							+ context.getString(R.string.reduce), discount+"",
							PayDetailsAdapter.TYPE_REDUCE,"");
					getOrderEvaluationActivity().dragLayout
							.setPayDetailList(list_paydetail_more);
					}catch(Exception e){}
				}
			});
			initImageLoad();
		}
		getOrderDetail(order_id, false);
		onAixinActivity();
	}

	/**
	 * 设置支付列表
	 */
	private void onSetPayList() {
		list = new ArrayList<Map<String, String>>();
		Map<String, String> map = new HashMap<String, String>();
		if(Value.isNEW) {
		// 余额
		map.put(PayAdapter.TYPE, PayAdapter.TYPE_YUE);
		map.put(PayAdapter.TEXT, context.getString(R.string.pay_way_yue));
		map.put(PayAdapter.DISCOUNT, getOrderEvaluationActivity().DISCOUNT_YUE);
		list.add(map);
		}
		// 支付宝
		map = new HashMap<String, String>();
		map.put(PayAdapter.TYPE, PayAdapter.TYPE_ALIPAY);
		map.put(PayAdapter.TEXT, context.getString(R.string.pay_way_alipay));
		map.put(PayAdapter.DISCOUNT,
				getOrderEvaluationActivity().DISCOUNT_ALIPAY);
		list.add(map);
		// 微信
		map = new HashMap<String, String>();
		map.put(PayAdapter.TYPE, PayAdapter.TYPE_WEIXIN);
		map.put(PayAdapter.TEXT, context.getString(R.string.pay_way_weixin));
		map.put(PayAdapter.DISCOUNT, getOrderEvaluationActivity().DISCOUNT_WEIXIN);
		map.put(PayAdapter.AVAILABLE, WXPayEntryActivity.isWXAppInstalledAndSupported(context) ? "true" : "false");
		list.add(map);
		//现金
		map = new HashMap<String, String>();
		map.put(PayAdapter.TYPE, PayAdapter.TYPE_LINE);
		map.put(PayAdapter.TEXT,context. getString(R.string.pay_way_line));
		map.put(PayAdapter.DISCOUNT, getOrderEvaluationActivity(). DISCOUNT_LINE);
		list.add(map);
		
		mPayAdapter = new PayAdapter(context, list);
		mPayAdapter.init(pay_id);
		listview_pay.setAdapter(mPayAdapter);
		ListViewHeight.setListViewHeightBasedOnChildren(listview_pay);
		listview_pay.setOnItemClickListener(new OnItemClickListener() {

			@Override
			public void onItemClick(AdapterView<?> arg0, View v, int position,
					long arg3) {
				pay_id = position;
				try {
					discount = Double.parseDouble(list.get(position).get(
							PayAdapter.DISCOUNT));
					pay = pay - discount;
					if (pay < 0)
						pay = 0;
				} catch (Exception e) {
				}
				//看是否点击了现金支付，然后更加是否是线上支付专享，的价格
				//判断是否是线上支付专享
					JSONObject json;
					try {
						String paymode = "";
						if(mMyOrderList.getDiscount()!=null&&mMyOrderList.getDiscount().getMetadata()!=null){
						json = new JSONObject(mMyOrderList.getDiscount().getMetadata());
						paymode = json.getString("paymode");
						}
						list_paydetail.clear();
						// 添加车费总计
						addPayDetail(context.getString(R.string.total_fare),
								total_fare + "",
								PayDetailsAdapter.TYPE_PRICE, "",true);
						if (getYMStatus() == STATUS_PAY) {
							int sale_type = 0;
							double sale_amount=0;
							try{
								sale_type=mMyOrderList.getPrice_Detail().getSaleType();
								sale_amount=mMyOrderList.getPrice_Detail().getSaleAmount();
							}catch(Exception e){}
							if(CouponUtils.isMarkOnline(paymode)||sale_type==UsableSale.sale_type_online){
								// 线上支付专享则不需要有优惠。需支付
								if (list.get(pay_id).get(PayAdapter.TYPE).equals(PayAdapter.TYPE_LINE)){
									pay = Double.parseDouble(FormatUtil.onFormatPrice(mMyOrderList.getPrice_Detail().getActual_price()))- discount;
								}else{
									//单位元
									double double_coupon;
									//如果是线上支付立减则，取sale_amount的值
									if(sale_type==UsableSale.sale_type_online){
										double_coupon=Double.parseDouble(FormatUtil.onFormatPrice(sale_amount));
									}else{
									//如果是线上支付专享则取优惠劵	
										double_coupon=coupon;
									}
									pay = Double.parseDouble(FormatUtil.onFormatPrice(mMyOrderList.getPrice_Detail().getActual_price()))- discount-double_coupon;
									// 添加优惠劵
									addCouponPayDetail(false);
								}
							}else{
								pay=Double.parseDouble(FormatUtil.onFormatPrice(mMyOrderList.getPrice_Detail().getActual_price()))- discount;
								// 添加优惠劵
								addCouponPayDetail(false);
							}
						}
					} catch (JSONException e) {}
				/////////
				
				tv_pay.setText(FormatUtil.onFormatDecimal(pay));
				if (getYMStatus() == STATUS_PAY) {
					tv_confirm.setText(String.format(
							context.getString(R.string.confirm_pay), tv_pay.getText()));
				}
				ViewHolder vHollder = (ViewHolder) v.getTag();
				if (!vHollder.cb_pay.isChecked()) {
					vHollder.cb_pay.toggle();
				}
				for (int i = 0; i < list.size(); i++) {
					if (i == position) {
						mPayAdapter.isSelected.put(i, true);
					} else {
						mPayAdapter.isSelected.put(i, false);
					}
				}
				mPayDetailsAdapter.notifyDataSetChanged();
				ListViewHeight
				.setListViewHeightBasedOnChildren(listview_paydetail);
				mPayAdapter.notifyDataSetInvalidated();
			}
		});
	}

	/**
	 * @param name  名字
	 * @param money 价钱
	 * @param type  类型
	 * @param mark  标记1,t通过传递paymode进行解析。
	 */
	public void addPayDetail(String name, String money, String type, String mark,boolean discount) {
		try{
        //mark
		//如果是线上专享却是点击线下支付，则不显示
		String str_mark ="";
		if(isLine!=PriceDetail.INT_LINE){
			str_mark= CouponUtils.getMark(context, mark, false);
		 }
		if(str_mark!=null&&!str_mark.equals("")&&!list.get(pay_id).get(PayAdapter.TYPE)
				.equals(PayAdapter.TYPE_LINE)){
		}else{
			str_mark="";
		}
		//打折
		String str_discount ="";
		double base_discount=Double.parseDouble(mMyOrderList.getPrice_Detail().getBaseDiscount());
		if(base_discount>100&&discount){
			str_discount=""+base_discount/100+"倍";
		}else if(base_discount<100&&discount){
			str_discount=""+FormatUtil.onFormatDecimal2(base_discount/10)+"折";
		}
		addPayDetail(name, money, type, str_mark, str_discount);
		}catch(Exception e){}
	}
	private void addPayDetail(String name, String money, String type, String mark,String base_discount) {
		Map<String, String> map = new HashMap<String, String>();
		map.put(PayDetailsAdapter.PAYDETAIL_NAME, name);
		map.put(PayDetailsAdapter.PAYDETAIL_MONEY, money);
		map.put(PayDetailsAdapter.PAYDETAIL_TYPE, type);
		map.put(PayDetailsAdapter.PAYDETAIL_MARK, mark);
		map.put(PayDetailsAdapter.PAYDETAIL_DISCOUNT, base_discount);
		list_paydetail.add(map);
	}
	/**
	 * 添加更加费用明细列表，及跳转到别的页面
	 */
	public void addPayDetail_More(String name, String money, String type,
			String mark) {
		try{
		String str_mark ="";
		if(isLine!=PriceDetail.INT_LINE){
		str_mark= CouponUtils.getMark(context, mark, false);
		}
		Map<String, String> map = new HashMap<String, String>();
		map.put(PayDetailsAdapter.PAYDETAIL_NAME, name);
		map.put(PayDetailsAdapter.PAYDETAIL_MONEY, money);
		map.put(PayDetailsAdapter.PAYDETAIL_TYPE, type);
		//如果是线上专享却是点击线下支付，则不显示
		if(str_mark!=null&&!str_mark.equals("")&&!list.get(pay_id).get(PayAdapter.TYPE)
				.equals(PayAdapter.TYPE_LINE)){
		map.put(PayDetailsAdapter.PAYDETAIL_MARK, str_mark);
		}
		list_paydetail_more.add(map);
		}catch(Exception e){}
	}

	public void addCouponPayDetail(boolean isMore) {
		int sale_type=0;
		try{sale_type=mMyOrderList.getPrice_Detail().getSaleType();}catch(Exception e){}
		//获取是优惠劵还是立减
		String str_coupon="";
		switch(sale_type){
		case UsableSale.sale_type_no:
			str_coupon=context.getString(R.string.end_coupon);
			break;
		case UsableSale.sale_type_submit:
			str_coupon="下单立减";
			try{coupon=Double.parseDouble(FormatUtil.onFormatPrice(mMyOrderList.getPrice_Detail().getSaleAmount()));}catch(Exception e){}
			break;
		case UsableSale.sale_type_online:
			str_coupon="线上支付立减";
			try{coupon=Double.parseDouble(FormatUtil.onFormatPrice(mMyOrderList.getPrice_Detail().getSaleAmount()));}catch(Exception e){}
			break;
		}
		
		// 添加优惠劵
		if (mMyOrderList.getDiscount() != null
				&& mMyOrderList.getDiscount().getMetadata() != null) {
			JSONObject json;
			try {
				json = new JSONObject(mMyOrderList.getDiscount().getMetadata());
				String paymode = "";
				if (getYMStatus() == STATUS_PAY) {
					paymode = json.getString("paymode");
				}
				//现金支付，却是线上专享则不添加，其他则可以添加
				if((sale_type==UsableSale.sale_type_online||CouponUtils.isMarkOnline(paymode))&&list.get(pay_id).get(PayAdapter.TYPE)
						.equals(PayAdapter.TYPE_LINE)){
					return;
				}				
					if (isMore) {
						addPayDetail_More(str_coupon, FormatUtil.onFormatDecimal(coupon), PayDetailsAdapter.TYPE_REDUCE, paymode);
					} else {
						addPayDetail(str_coupon,  FormatUtil.onFormatDecimal(coupon),
								PayDetailsAdapter.TYPE_REDUCE, paymode,false);
				}
			} catch (JSONException e) {
			}

		} else {
			//现金支付，却是线上专享则不添加，其他则可以添加
			if(sale_type==UsableSale.sale_type_online&&list.get(pay_id).get(PayAdapter.TYPE)
					.equals(PayAdapter.TYPE_LINE)){
				return;
			}
			if (isMore) {
				addPayDetail_More(str_coupon,  FormatUtil.onFormatDecimal(coupon),
						PayDetailsAdapter.TYPE_REDUCE, "");
			} else {
				addPayDetail(str_coupon,  FormatUtil.onFormatDecimal(coupon),
						PayDetailsAdapter.TYPE_REDUCE, "",false);
			}

		}
	}

	/**
	 * 显示状态，分别为，支付状态，评价状态，完成状态
	 */
	public void showStatus() {
		switch (getYMStatus()) {
		// 支付状态
		case STATUS_PAY:
			tv_need_pay.setText(R.string.need_pay);
			layout_payway.setVisibility(View.VISIBLE);
			layout_hint_paytype.setVisibility(View.GONE);

			setBtnCouponVisibility(false);
			listview_pay.setVisibility(View.VISIBLE);
			layout_cost.setVisibility(View.VISIBLE);
			layout_evaluate.setVisibility(View.GONE);
			layout_cost.setVisibility(View.VISIBLE);
			et_message.setVisibility(View.GONE);
			et_message2.setVisibility(View.GONE);
			layout_anonymous.setVisibility(View.GONE);
			rb_rating_b.setIsIndicator(false);
			rb_rating_b.setRating(0);
			text_offline_payment.setVisibility(View.VISIBLE);
			break;
		// 待评价状态
		case STATUS_EVA:
			tv_need_pay.setText(R.string.has_pay);
			layout_payway.setVisibility(View.GONE);
			layout_hint_paytype.setVisibility(View.VISIBLE);
			tv_hint_paytype.setText(pay_gate);

			setBtnCouponVisibility(true);
			listview_pay.setVisibility(View.GONE);
			layout_cost.setVisibility(View.VISIBLE);
			layout_evaluate.setVisibility(View.VISIBLE);
			layout_anonymous.setVisibility(View.VISIBLE);
			text_offline_payment.setVisibility(View.GONE);
			break;
		// 正在评价状态
		case STATUS_EVAING:
			tv_need_pay.setText(R.string.has_pay);
			layout_payway.setVisibility(View.GONE);
			layout_hint_paytype.setVisibility(View.GONE);

			setBtnCouponVisibility(false);
			layout_evaluate.setVisibility(View.VISIBLE);
			listview_pay.setVisibility(View.GONE);
			layout_cost_detail.setVisibility(View.GONE);
			layout_cost.setVisibility(View.GONE);
			et_message.setVisibility(View.VISIBLE);
			rb_rating_b.setStepSize(1);
			layout_anonymous.setVisibility(View.VISIBLE);
			text_offline_payment.setVisibility(View.GONE);
			new Handler().postAtTime(new Runnable() {
				@Override
				public void run() {
					rb_rating_b.setIsIndicator(false);
				}
			}, 200);
			break;
		// 完成状态
		case STATUS_FINISH:
			tv_need_pay.setText(R.string.has_pay);
			layout_payway.setVisibility(View.GONE);
			layout_hint_paytype.setVisibility(View.VISIBLE);
			tv_hint_paytype.setText(pay_gate);

			setBtnCouponVisibility(true);
			layout_evaluate.setVisibility(View.VISIBLE);
			listview_pay.setVisibility(View.GONE);
			layout_cost_detail.setVisibility(View.VISIBLE);
			layout_cost.setVisibility(View.VISIBLE);
			et_message.setVisibility(View.GONE);
			layout_anonymous.setVisibility(View.VISIBLE);
			et_message2.setVisibility(View.VISIBLE);
			et_message2.setText(mMyOrderList.getSuggest());
			rb_rating_b.setIsIndicator(true);
			isTouch = false;
			rb_rating_b.setStepSize(0.1F);
			rb_rating_b.setRating(FormatUtil.onFormatStar(mMyOrderList
					.getStar()));
			text_offline_payment.setVisibility(View.GONE);
			break;
		}
	}
	private void onSetTitle(int ym_status) {
		this.ym_status = ym_status;
		switch (getYMStatus()) {
		// 支付状态
		case STATUS_PAY:
			getOrderEvaluationActivity().setTitle(true, context.getString(R.string.title_pay), -1,context.getString(R.string.complaint));
			break;
		// 待评价状态
		case STATUS_EVA:
			getOrderEvaluationActivity().setTitle(true, context.getString(R.string.title_pay_finish), -1,context.getString(R.string.complaint));
			break;
		// 正在评价状态
		case STATUS_EVAING:
			getOrderEvaluationActivity().setTitle(true, context.getString(R.string.title_pay_finish), -1,context.getString(R.string.complaint));
			break;
		// 完成状态
		case STATUS_FINISH:
			getOrderEvaluationActivity().setTitle(true, context.getString(R.string.title_pay_finish), -1,context.getString(R.string.complaint));
			break;
		}
	}
	/**
	 * 设置状态
	 */
	public void setYMStatus(int ym_status) {
		this.ym_status = ym_status;
		onSetTitle(getYMStatus());
		switch (getYMStatus()) {
		// 支付状态
		case STATUS_PAY:
			// mMyOrderList.setValuate_status(Value.PAY_NO+"");
			tv_confirm.setText(String.format(
					context.getString(R.string.confirm_pay), tv_pay.getText()));
			ib_sj.setVisibility(View.VISIBLE);
			break;
		// 待评价状态
		case STATUS_EVA:
			mMyOrderList.setValuate_status(Value.VALUATE_STATUS_NO + "");
			tv_confirm.setText(R.string.agin_xiadan);
			ib_sj.setVisibility(View.GONE);
			break;
		// 正在评价状态
		case STATUS_EVAING:
			mMyOrderList.setValuate_status(Value.VALUATE_STATUS_NO + "");
			tv_confirm.setText(R.string.submit_evaluation);
			ib_sj.setVisibility(View.GONE);
			break;
		// 完成状态
		case STATUS_FINISH:
			mMyOrderList.setValuate_status(Value.VALUATE_STATUS + "");
			tv_confirm.setText(R.string.agin_xiadan);
			ib_sj.setVisibility(View.GONE);
			break;
		}
		showStatus();
		db_myorder.onUpdate(mMyOrderList);
		onAixinActivity();
	}

	/**
	 * 获取订单详情
	 */
	public void getOrderDetail(String order_id, boolean isLoading) {
		OrderDetailBuild mOrderDetail = new OrderDetailBuild(context);
		mOrderDetail.uid = mApplication.getUid();
		mOrderDetail.access_token = mApplication.getToken();
		mOrderDetail.order_id = order_id;
		mOrderDetailTask = new OrderDetailTask(context, mOrderDetail, isLoading);
		mOrderDetailTask.executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
	}

	/**
	 * 获取当前状态，
	 */
	public int getYMStatus() {
		return ym_status;
	}

	/**
	 * 订单详情
	 */
	private class OrderDetailTask extends BaseAsyncTask {

		private OrderDetailBuild mOrderDetail;

		public OrderDetailTask(Context context, OrderDetailBuild mOrderDetail,
				boolean isLoading) {
			super(context, isLoading);
			this.mOrderDetail = mOrderDetail;
		}

		@Override
		public void onSuccess(int status,Object object) {
			isSuccess = true;
			if (object != null) {
				OrderDetails mOrderDetails = (OrderDetails) object;
				if (mOrderDetails != null) {
					mMyOrderList = mOrderDetails.getDetails();
					//如果是确认中...却订单已经完成了，则跳转到待评价
					if(tv_confirm.getText().toString().equals(context.getString(R.string.btn_confirmation))&&mMyOrderList.getOrder_status()==Value.ORDER_STATUS_FINISH){
						onPaySuccuss();
					}else{
					// ////////////////////////
					PriceDetail price_detail = mMyOrderList
								.getPrice_Detail();
					// 车费
					if(price_detail!=null){
						fare =Double.parseDouble(FormatUtil.onFormatPrice(price_detail.getPrice()));
					}else{
						fare =Double.parseDouble(FormatUtil.onFormatPrice(mMyOrderList.getPrice()));
					}
					//如果是市内单，则车费另外获取，在PriceDetail里面
					if (price_detail != null&&mMyOrderList.getOrder_type() == Value.ORDER_TYPE_SN) {
						fare=Double.parseDouble(FormatUtil.onFormatPrice(price_detail.getMetered_fee()));
					}
					
					//优惠劵类型
					int coupon_type = CouponUtils.coupon_type_0;
					try {
						coupon_type = Integer.parseInt(mMyOrderList
								.getDiscount().getType());
					} catch (Exception e) {
					}
					if (price_detail != null&&price_detail.getActual_price()!=-1) {
						coupon = price_detail.getDiscountAmt();
//						switch (coupon_type) {
//						case CouponUtils.coupon_type_0:
//				    	case CouponUtils.coupon_type_3:break;
//						case CouponUtils.coupon_type_1:
//							coupon=CouponUtils.getZhekouSum(mOrderDetails.getDetails().getPrice(),coupon);
//							break;
//						case CouponUtils.coupon_type_2:
//							coupon=CouponUtils.getTiyanSum(mOrderDetails.getDetails().getPrice(),coupon);
//							break;
//						}
						mMyOrderList.setPrice_Detail(price_detail);
						// 需支付
						pay = Double.parseDouble(FormatUtil
								.onFormatPrice(price_detail.getActual_price()))
								- discount;
						//带支付状态的需支付，需要自己计算
						JSONObject json;
						try {
							String paymode = "";
							if(mMyOrderList.getDiscount()!=null&&mMyOrderList.getDiscount().getMetadata()!=null){
							json = new JSONObject(mMyOrderList.getDiscount().getMetadata());
							paymode = json.getString("paymode");
							}
							if (getYMStatus() == STATUS_PAY) {
								int sale_type = 0;
								double sale_amount=0;
								try{
									sale_type=mMyOrderList.getPrice_Detail().getSaleType();
									sale_amount=mMyOrderList.getPrice_Detail().getSaleAmount();
								    }catch(Exception e){}
								if(CouponUtils.isMarkOnline(paymode)||sale_type==UsableSale.sale_type_online){
									if(sale_type==UsableSale.sale_type_online){
										pay=pay-Double.parseDouble(FormatUtil.onFormatPrice(sale_amount));
									}else{
										pay=pay-coupon;	
									}
								}
							}
						} catch (JSONException e) {
						}
						// 车费总计
						total_fare = Double.parseDouble(FormatUtil
								.onFormatPrice(price_detail.getTotal()));
						// 支付方式
						if (price_detail.getPay_gate() != null&&mMyOrderList.getOrder_status() == Value.ORDER_STATUS_FINISH) {
							if (price_detail.getPay_gate().equals(
									PriceDetail.ALIPAY)) {
								pay_gate = context
										.getString(R.string.pay_way_alipay);
								isLine=PriceDetail.INT_ONLINE;
							} else if (price_detail.getPay_gate().equals(
									PriceDetail.WEIXIN)||price_detail.getPay_gate().equals(
											PriceDetail.WEIXIN_JSAPI)|| price_detail.getPay_gate().equals(
													PriceDetail.WEIXIN_NATIVE)) {
								pay_gate = context
										.getString(R.string.pay_way_weixin);
								isLine=PriceDetail.INT_ONLINE;
							} else if (price_detail.getPay_gate().equals(
									PriceDetail.LINE)) {
								pay_gate = context
										.getString(R.string.pay_way_line);
								isLine=PriceDetail.INT_LINE;
							} else if (price_detail.getPay_gate().equals(
									PriceDetail.YUE)) {
								pay_gate = context
										.getString(R.string.pay_way_yue);
								isLine=PriceDetail.INT_ONLINE;
							}
							tv_hint_paytype.setText(pay_gate);
							setYMStatus(getYMStatus());
							if(isPaySuccuss){
								isPaySuccuss=false;
								getOrderEvaluationActivity().onShowCoupon(isLine);
							}
						}
						tv_hint_paytype.setText(pay_gate);
					} else {
						if(mMyOrderList.getDiscount()!=null){
							coupon=mMyOrderList.getDiscount().getSum();
							switch (coupon_type) {
							case CouponUtils.coupon_type_0:
							case CouponUtils.coupon_type_3:break;
							case CouponUtils.coupon_type_1:
								coupon=CouponUtils.getZhekouSum(mMyOrderList.getPrice(),coupon);
								break;
							case CouponUtils.coupon_type_2:
								coupon=CouponUtils.getTiyanSum(mMyOrderList.getPrice(),coupon);
								break;
							}
						}
						// 车费总计=车费
						total_fare = fare;
						pay = total_fare - discount-coupon;
					}
					if (pay < 0)
						pay = 0;
					tv_pay.setText(FormatUtil.onFormatDecimal(pay));
					if (getYMStatus() == STATUS_PAY) {
						tv_confirm.setText(String.format(
								context.getString(R.string.confirm_pay),
								tv_pay.getText()));
					}
					// ////////////////////////
						rb_rating_s.setRating(FormatUtil
								.onFormatStar((float) mMyOrderList.getDriver_star()));
						tv_rating.setText(FormatUtil
								.onFormatStar((float) mMyOrderList.getDriver_star())
								+ "");
					if (mMyOrderList.getCar_NO() != null)
						tv_car_no.setText(mMyOrderList
								.getCar_NO());
					if (et_message2.getText().toString().equals(""))
						et_message2.setText(mMyOrderList
								.getSuggest());

					if (mMyOrderList.getValuate_status() != null
							&& Integer.parseInt(mMyOrderList
									.getValuate_status()) == (Value.VALUATE_STATUS)) {// 如果该订单已完成，则显示完成界面
							rb_rating_b.setRating(FormatUtil.onFormatStar((mMyOrderList.getStar())));
					}
					
					db_myorder.onUpdate(mMyOrderList);
					
					list_paydetail.clear();
					// 添加车费总计
					addPayDetail(context.getString(R.string.total_fare),
							total_fare + "",
							PayDetailsAdapter.TYPE_PRICE, "",true);
					// 添加优惠劵
					addCouponPayDetail(false);
					mPayDetailsAdapter.notifyDataSetChanged();
					ListViewHeight.setListViewHeightBasedOnChildren(listview_paydetail);
				  }
				}
			} else {
				ToastUtil.showToast(context, R.string.no_network);
			}
		}

		@Override
		public void onFailed(int status, String msg) {
			getOrderDetail(order_id, false);
		}

		@Override
		protected Object doInBackground(Object... params) {
			// TODO Auto-generated method stub
			String json = new JsonBuild().setModel(mOrderDetail).getJson();
			return new OrderDetailNet(context, json);
		}
	}

	/**
	 * 评价
	 */
	public class OrderEvaluateTask extends BaseAsyncTask {

		private OrderEvaluate mOrderEvaluate;

		public OrderEvaluateTask(Context context, OrderEvaluate mOrderEvaluate) {
			super(context);
			this.mOrderEvaluate = mOrderEvaluate;
		}

		@Override
		protected Object doInBackground(Object... params) {
			// TODO Auto-generated method stub
			String json = new JsonBuild().setModel(mOrderEvaluate).getJson();
			return new OrderEvaluateNet(context, json);
		}

		@Override
		public void onSuccess(int status,Object object) {
			ToastUtil.showToast(context, R.string.submit_success);
			et_message2.setText(et_message.getText().toString());
			mMyOrderList.setStar(rb_rating_b.getRating() * 20);
			setYMStatus(STATUS_FINISH);
			getOrderDetail(order_id, true);
		}

		@Override
		public void onFailed(int status, String msg) {
			// TODO Auto-generated method stub
			ToastUtil.showToast(context,
					getResources().getString(R.string.no_network));
		}
	}

	/**
	 * 加载图片
	 */
	private void initImageLoad() {
	}

	public View getContent() {
		return mContent;
	}

	public void setLeftShadowDrawable(int resId) {
		setLeftShadowDrawable(getContext().getResources().getDrawable(resId));
	}

	public void setLeftShadowDrawable(Drawable d) {
		mLeftShadowDrawable = d;
		mLeftShadowWidth = d.getIntrinsicWidth();
		invalidate();
	}

	public void setLeftShadowWidthRes(int resId) {
		setLeftShadowWidth((int) getResources().getDimension(resId));
	}

	public void setLeftShadowWidth(int pixels) {
		mLeftShadowWidth = pixels;
		invalidate();
	}

	public void setRightShadowDrawable(int resId) {
		setRightShadowDrawable(getContext().getResources().getDrawable(resId));
	}

	public void setRightShadowDrawable(Drawable d) {
		mRightShadowDrawable = d;
		mRightShadowWidth = d.getIntrinsicWidth();
		invalidate();
	}

	public void setRightShadowWidthRes(int resId) {
		setRightShadowWidth((int) getResources().getDimension(resId));
	}

	public void setRightShadowWidth(int pixels) {
		mRightShadowWidth = pixels;
		invalidate();
	}

	public void setLeftFadeEnabled(boolean b) {
		mLeftFadeEnabled = b;
	}

	public void setLeftFadeDegree(float degree) {
		if (degree > 1.0f || degree < 0.0f)
			throw new IllegalStateException(
					"The LeftFadeDegree must be between 0.0f and 1.0f");
		mLeftFadeDegree = degree;
	}

	public void setRightFadeEnabled(boolean b) {
		mRightFadeEnabled = b;
	}

	public void setRightFadeDegree(float degree) {
		if (degree > 1.0f || degree < 0.0f)
			throw new IllegalStateException(
					"The RightFadeDegree must be between 0.0f and 1.0f");
		mRightFadeDegree = degree;
	}

	public void setBehindStackCount(int count) {
		mBehindStackCount = count;
	}

	public int getBehindStackCount() {
		return mBehindStackCount;
	}

	public boolean isSlidingEnabled() {
		return mEnabled;
	}

	public void setSlidingEnabled(boolean b) {
		mEnabled = b;
	}

	public boolean isCardClose() {
		return mCurItem == 0 || mCurItem == 2;
	}

	public int getCardWidth() {
		return mContent.getWidth();
	}

	public void addIgnoredView(View v) {
		if (!mIgnoredViews.contains(v)) {
			mIgnoredViews.add(v);
		}
	}

	public void removeIgnoredView(View v) {
		mIgnoredViews.remove(v);
	}

	public void clearIgnoredViews() {
		mIgnoredViews.clear();
	}

	private void getHitRect(View v, Rect rect) {
		v.getHitRect(rect);
		ViewParent parent = v.getParent();
		while (parent != null && parent != this) {
			View _parent = (View) parent;
			Rect parentRect = new Rect();
			_parent.getHitRect(parentRect);
			rect.left += parentRect.left;
			rect.right += parentRect.left;
			rect.top += parentRect.top;
			rect.bottom += parentRect.top;
			parent = parent.getParent();
		}
	}

	private boolean isInIgnoredView(MotionEvent ev) {
		Rect rect = new Rect();
		for (View v : mIgnoredViews) {
			getHitRect(v, rect);
			if (rect.contains((int) ev.getX(), (int) ev.getY()))
				return true;
		}
		return false;
	}

	private boolean marginTouchAllowed(int x) {
		int left = mContent.getLeft();
		int right = mContent.getRight();
		if (mSlidingMode == SLIDINGMODE_LEFT) {
			return (x >= left && x <= mMarginThreshold + left);
		} else if (mSlidingMode == SLIDINGMODE_RIGHT) {
			return (x <= right && x >= right - mMarginThreshold);
		} else if (mSlidingMode == SLIDINGMODE_LEFT_RIGHT) {
			return (x >= left && x <= mMarginThreshold + left)
					|| (x <= right && x >= right - mMarginThreshold);
		}
		return false;
	}

	private boolean thisTouchAllowed(MotionEvent ev) {
		int x = (int) (ev.getX() + mScrollX);
		if (!isCardClose()) {
			switch (mTouchMode) {
			case TOUCHMODE_FULLSCREEN:
			case TOUCHMODE_BOUND:
				return !isInIgnoredView(ev);
			case TOUCHMODE_NONE:
				return false;
			case TOUCHMODE_MARGIN:
				return marginTouchAllowed(x);
			}
		}
		return false;
	}

	private boolean thisSlideAllowed(float dx) {
		if (!isCardClose()) {
			if (mSlidingMode == SLIDINGMODE_LEFT) {
				return dx > 0;
			} else if (mSlidingMode == SLIDINGMODE_RIGHT) {
				return dx < 0;
			} else if (mSlidingMode == SLIDINGMODE_LEFT_RIGHT) {
				return true;
			}
		}
		return false;
	}

	private int getLeftBound() {
		if (mSlidingMode == SLIDINGMODE_LEFT) {
			return mContent.getLeft()
					- ((mTouchMode == TOUCHMODE_BOUND) ? (int) (getCardWidth() * 0.33f + 0.5f)
							: getCardWidth());
		} else if (mSlidingMode == SLIDINGMODE_RIGHT) {
			return mContent.getLeft();
		} else if (mSlidingMode == SLIDINGMODE_LEFT_RIGHT) {
			return mContent.getLeft()
					- ((mTouchMode == TOUCHMODE_BOUND) ? (int) (getCardWidth() * 0.33f + 0.5f)
							: getCardWidth());
		}
		return 0;
	}

	private int getRightBound() {
		if (mSlidingMode == SLIDINGMODE_LEFT) {
			return mContent.getLeft();
		} else if (mSlidingMode == SLIDINGMODE_RIGHT) {
			return mContent.getLeft()
					+ ((mTouchMode == TOUCHMODE_BOUND) ? (int) (getCardWidth() * 0.33f + 0.5f)
							: getCardWidth());
		} else if (mSlidingMode == SLIDINGMODE_LEFT_RIGHT) {
			return mContent.getLeft()
					+ ((mTouchMode == TOUCHMODE_BOUND) ? (int) (getCardWidth() * 0.33f + 0.5f)
							: getCardWidth());
		}
		return 0;
	}

	private void startDrag() {
		mIsBeingDragged = true;
		setScrollState(SCROLL_STATE_DRAGGING);
	}

	private void endDrag() {
		mIsBeingDragged = false;
		mIsUnableToDrag = false;
		mActivePointerId = INVALID_POINTER;

		if (mVelocityTracker != null) {
			mVelocityTracker.recycle();
			mVelocityTracker = null;
		}
	}

	private void determineDrag(MotionEvent ev) {
		final int activePointerId = mActivePointerId;
		if (activePointerId == INVALID_POINTER)
			return;
		final int pointerIndex = findPointerIndex(ev, activePointerId);
		final float x = MotionEventCompat.getX(ev, pointerIndex);
		final float dx = x - mLastMotionX;
		final float xDiff = Math.abs(dx);
		final float y = MotionEventCompat.getY(ev, pointerIndex);
		final float dy = y - mLastMotionY;
		final float yDiff = Math.abs(dy);
		if (xDiff > mTouchSlop && xDiff > yDiff && thisSlideAllowed(dx)) {
			startDrag();
			mLastMotionX = x;
			mLastMotionY = y;
			setScrollingCacheEnabled(true);
			// TODO add back in touch slop check
		} else if (xDiff > mTouchSlop) {
			mIsUnableToDrag = true;
		}
	}

	private int determineTargetPage(float pageOffset, int velocity, int deltaX) {
		if (mTouchMode == TOUCHMODE_BOUND) {
			return mCurItem;
		}
		int targetPage = mCurItem;
		if (Math.abs(deltaX) > mFlingDistance
				&& Math.abs(velocity) > mMinimumVelocity) {
			if (velocity > 0 && deltaX > 0) {
				targetPage -= 1;
			} else if (velocity < 0 && deltaX < 0) {
				targetPage += 1;
			}
		} else {
			targetPage = (int) Math.round(mCurItem + pageOffset);
		}
		return targetPage;
	}

	protected boolean canScroll(View v, boolean checkV, int dx, int x, int y) {
		if (v instanceof ViewGroup) {
			final ViewGroup group = (ViewGroup) v;
			final int scrollX = v.getScrollX();
			final int scrollY = v.getScrollY();
			final int count = group.getChildCount();
			// Count backwards - let topmost views consume scroll distance
			// first.
			for (int i = count - 1; i >= 0; i--) {
				final View child = group.getChildAt(i);
				if (x + scrollX >= child.getLeft()
						&& x + scrollX < child.getRight()
						&& y + scrollY >= child.getTop()
						&& y + scrollY < child.getBottom()
						&& canScroll(child, true, dx,
								x + scrollX - child.getLeft(), y + scrollY
										- child.getTop())) {
					return true;
				}
			}
		}

		return checkV && ViewCompat.canScrollHorizontally(v, -dx);
	}

	@Override
	public boolean dispatchKeyEvent(KeyEvent event) {
		// Let the focused view and/or our descendants get the key first
		return super.dispatchKeyEvent(event) || executeKeyEvent(event);
	}

	/**
	 * You can call this function yourself to have the scroll view perform
	 * scrolling from a key event, just as if the event had been dispatched to
	 * it by the view hierarchy.
	 * 
	 * @param event
	 *            The key event to execute.
	 * @return Return true if the event was handled, else false.
	 */
	public boolean executeKeyEvent(KeyEvent event) {
		boolean handled = false;
		if (event.getAction() == KeyEvent.ACTION_DOWN) {
			switch (event.getKeyCode()) {
			case KeyEvent.KEYCODE_DPAD_LEFT:
				handled = arrowScroll(FOCUS_LEFT);
				break;
			case KeyEvent.KEYCODE_DPAD_RIGHT:
				handled = arrowScroll(FOCUS_RIGHT);
				break;
			case KeyEvent.KEYCODE_TAB:
				if (Build.VERSION.SDK_INT >= 11) {
					// The focus finder had a bug handling FOCUS_FORWARD and
					// FOCUS_BACKWARD
					// before Android 3.0. Ignore the tab key on those
					// devices.
					if (KeyEventCompat.hasNoModifiers(event)) {
						handled = arrowScroll(FOCUS_FORWARD);
					} else if (KeyEventCompat.hasModifiers(event,
							KeyEvent.META_SHIFT_ON)) {
						handled = arrowScroll(FOCUS_BACKWARD);
					}
				}
				break;
			}
		}
		return handled;
	}

	public boolean arrowScroll(int direction) {
		View currentFocused = findFocus();
		if (currentFocused == this)
			currentFocused = null;

		boolean handled = false;

		View nextFocused = FocusFinder.getInstance().findNextFocus(this,
				currentFocused, direction);
		if (nextFocused != null && nextFocused != currentFocused) {
			if (direction == View.FOCUS_LEFT) {
				handled = nextFocused.requestFocus();
			} else if (direction == View.FOCUS_RIGHT) {
				if (currentFocused != null
						&& nextFocused.getLeft() <= currentFocused.getLeft()) {
					handled = pageRight();
				} else {
					handled = nextFocused.requestFocus();
				}
			}
		} else if (direction == FOCUS_LEFT || direction == FOCUS_BACKWARD) {
			// Trying to move left and nothing there; try to page.
			handled = pageLeft();
		} else if (direction == FOCUS_RIGHT || direction == FOCUS_FORWARD) {
			// Trying to move right and nothing there; try to page.
			handled = pageRight();
		}
		if (handled) {
			playSoundEffect(SoundEffectConstants
					.getContantForFocusDirection(direction));
		}
		return handled;
	}

	boolean pageLeft() {
		if (mCurItem > 0) {
			setCurrentItem(mCurItem - 1, true);
			return true;
		}
		return false;
	}

	boolean pageRight() {
		if (mCurItem <= 1) {
			setCurrentItem(mCurItem + 1, true);
			return true;
		}
		return false;
	}

	private void onSecondaryPointerUp(MotionEvent ev) {
		if (DEBUG)
			Log.v(TAG, "onSecondaryPointerUp called");
		final int pointerIndex = MotionEventCompat.getActionIndex(ev);
		final int pointerId = MotionEventCompat.getPointerId(ev, pointerIndex);
		if (pointerId == mActivePointerId) {
			// This was our active pointer going up. Choose a new
			// active pointer and adjust accordingly.
			final int newPointerIndex = pointerIndex == 0 ? 1 : 0;
			mLastMotionX = MotionEventCompat.getX(ev, newPointerIndex);
			mActivePointerId = MotionEventCompat.getPointerId(ev,
					newPointerIndex);
			if (mVelocityTracker != null) {
				mVelocityTracker.clear();
			}
		}
	}

	private int findPointerIndex(MotionEvent event, int pointerId) {
		int index = MotionEventCompat.findPointerIndex(event, pointerId);
		if (index == INVALID_POINTER) {
			index = 0;
		}
		return index;
	}

	@Override
	public boolean onInterceptTouchEvent(MotionEvent ev) {

		if (!mEnabled)
			return true;

		if (isCardClose())
			return false;

		final int action = ev.getAction() & MotionEventCompat.ACTION_MASK;

		if (DEBUG)
			if (action == MotionEvent.ACTION_DOWN)
				Log.v(TAG, "Received ACTION_DOWN");

		if (action == MotionEvent.ACTION_CANCEL
				|| action == MotionEvent.ACTION_UP
				|| (action != MotionEvent.ACTION_DOWN && mIsUnableToDrag)) {
			endDrag();
			return false;
		}

		switch (action) {
		case MotionEvent.ACTION_MOVE:
			determineDrag(ev);
			break;
		case MotionEvent.ACTION_DOWN:
			mLastMotionX = mInitialMotionX = ev.getX();
			mLastMotionY = ev.getY();
			mActivePointerId = MotionEventCompat.getPointerId(ev, 0);
			if (thisTouchAllowed(ev)) {
				completeScroll();
				mIsBeingDragged = false;
				mIsUnableToDrag = false;
			} else {
				mIsUnableToDrag = true;
			}
			break;
		case MotionEventCompat.ACTION_POINTER_UP:
			onSecondaryPointerUp(ev);
			break;
		}

		if (!mIsBeingDragged) {
			if (mVelocityTracker == null) {
				mVelocityTracker = VelocityTracker.obtain();
			}
			mVelocityTracker.addMovement(ev);
		}
		return mIsBeingDragged;
	}

	@Override
	public boolean onTouchEvent(MotionEvent ev) {

		if (!mEnabled)
			return true;

		if (isCardClose())
			return false;

		if (!mIsBeingDragged && !thisTouchAllowed(ev))
			return false;

		// if (!mIsBeingDragged && !mQuickReturn)
		// return false;

		final int action = ev.getAction();

		if (mVelocityTracker == null) {
			mVelocityTracker = VelocityTracker.obtain();
		}
		mVelocityTracker.addMovement(ev);

		switch (action & MotionEventCompat.ACTION_MASK) {
		case MotionEvent.ACTION_DOWN:
			// Remember where the motion event started
			mActivePointerId = MotionEventCompat.getPointerId(ev, 0);
			mLastMotionX = mInitialMotionX = ev.getX();
			mLastMotionY = ev.getY();
			break;
		case MotionEvent.ACTION_MOVE:
			if (!mIsBeingDragged) {
				determineDrag(ev);
				if (mIsUnableToDrag)
					return false;
			}
			if (mIsBeingDragged) {
				// Scroll to follow the motion event
				final int activePointerIndex = findPointerIndex(ev,
						mActivePointerId);
				final float x = MotionEventCompat.getX(ev, activePointerIndex);
				float deltaX = mLastMotionX - x;
				if (mTouchMode == TOUCHMODE_BOUND) {
					deltaX = deltaX * 0.33f + 0.5f;
				}
				mLastMotionX = x;
				float oldScrollX = getScrollX();
				float scrollX = oldScrollX + deltaX;
				final float leftBound = getLeftBound();
				final float rightBound = getRightBound();
				if (scrollX < leftBound) {
					scrollX = leftBound;
				} else if (scrollX > rightBound) {
					scrollX = rightBound;
				}
				// Don't lose the rounded component
				mLastMotionX += scrollX - (int) scrollX;
				scrollTo((int) scrollX, getScrollY());
				pageScrolled((int) scrollX);
			}
			break;
		case MotionEvent.ACTION_UP:
			if (mIsBeingDragged) {
				final VelocityTracker velocityTracker = mVelocityTracker;
				velocityTracker.computeCurrentVelocity(1000, mMaximumVelocity);
				int initialVelocity = (int) VelocityTrackerCompat.getXVelocity(
						velocityTracker, mActivePointerId);
				final int scrollX = getScrollX();
				final float pageOffset = (float) (scrollX - getDestScrollX(mCurItem))
						/ getCardWidth();
				final int activePointerIndex = findPointerIndex(ev,
						mActivePointerId);
				final float x = MotionEventCompat.getX(ev, activePointerIndex);
				final int totalDelta = (int) (x - mInitialMotionX);
				int nextPage = determineTargetPage(pageOffset, initialVelocity,
						totalDelta);
				setCurrentItemInternal(nextPage, true, true, initialVelocity);
				mActivePointerId = INVALID_POINTER;
				endDrag();
			}
			break;
		case MotionEvent.ACTION_CANCEL:
			if (mIsBeingDragged) {
				setCurrentItemInternal(mCurItem, true, true);
				mActivePointerId = INVALID_POINTER;
				endDrag();
			}
			break;
		case MotionEventCompat.ACTION_POINTER_DOWN: {
			final int indexx = MotionEventCompat.getActionIndex(ev);
			mLastMotionX = MotionEventCompat.getX(ev, indexx);
			mActivePointerId = MotionEventCompat.getPointerId(ev, indexx);
			break;
		}
		case MotionEventCompat.ACTION_POINTER_UP:
			onSecondaryPointerUp(ev);
			try {
				mLastMotionX = MotionEventCompat.getX(ev,
						findPointerIndex(ev, mActivePointerId));
			} catch (Exception e) {
				// ignore.��֪����ν�����ȴ��ȸ�v4����ViewPager�ĸ����޸�
			}
			break;
		}
		return true;
	}

	private void drawLeftShadow(Canvas canvas) {
		if (mLeftShadowDrawable == null || mLeftShadowWidth <= 0)
			return;
		int left = mContent.getLeft() - mLeftShadowWidth;
		mLeftShadowDrawable.setBounds(left, 0, left + mLeftShadowWidth,
				getHeight());
		mLeftShadowDrawable.draw(canvas);
	}

	private void drawRightShadow(Canvas canvas, int behindCount) {
		if (mRightShadowDrawable == null || mRightShadowWidth <= 0)
			return;
		int left = mContent.getRight();
		mStackPaint.setColor(Color.WHITE);
		if (behindCount == 0) {
			mRightShadowDrawable.setBounds(left, 0, left + mRightShadowWidth,
					getHeight());
			mRightShadowDrawable.draw(canvas);
		} else if (behindCount == 1) {
			int shadowWidth = mRightShadowWidth;
			canvas.drawRect(left, shadowWidth, left + shadowWidth, getHeight(),
					mStackPaint);
			mRightShadowDrawable.setBounds(left, 0, left + shadowWidth,
					getHeight());
			mRightShadowDrawable.draw(canvas);
			mRightShadowDrawable.setBounds(left + shadowWidth, shadowWidth,
					left + shadowWidth * 2, getHeight());
			mRightShadowDrawable.draw(canvas);
		} else {
			int shadowWidth = mRightShadowWidth;
			canvas.drawRect(left, shadowWidth, left + shadowWidth, getHeight(),
					mStackPaint);
			mRightShadowDrawable.setBounds(left, 0, left + shadowWidth,
					getHeight());
			mRightShadowDrawable.draw(canvas);
			canvas.drawRect(left + shadowWidth, shadowWidth * 2, left
					+ shadowWidth * 2, getHeight(), mStackPaint);
			mRightShadowDrawable.setBounds(left + shadowWidth, shadowWidth,
					left + shadowWidth * 2, getHeight());
			mRightShadowDrawable.draw(canvas);
			mRightShadowDrawable.setBounds(left + shadowWidth * 2,
					shadowWidth * 2, left + shadowWidth * 3, getHeight());
			mRightShadowDrawable.draw(canvas);
		}
	}

	private void drawShadow(Canvas canvas) {
		// if (mSlidingMode == SLIDINGMODE_LEFT) {
		// drawLeftShadow(canvas);
		// } else if (mSlidingMode == SLIDINGMODE_RIGHT) {
		// drawRightShadow(canvas, mBehindStackCount);
		// } else if (mSlidingMode == SLIDINGMODE_LEFT_RIGHT) {
		// drawLeftShadow(canvas);
		// drawRightShadow(canvas, mBehindStackCount);
		// }
	}

	private void drawLeftFade(Canvas canvas, float openPercent) {
		if (!mLeftFadeEnabled)
			return;
		final int alpha = (int) (mLeftFadeDegree * 255 * Math
				.abs(1 - openPercent));
		mLeftFadePaint.setColor(Color.argb(alpha, 0, 0, 0));
		int left = mContent.getLeft() - getCardWidth();
		int right = mContent.getLeft();
		canvas.drawRect(left, 0, right, getHeight(), mLeftFadePaint);
	}

	private void drawRightFade(Canvas canvas, float openPercent) {
		if (!mRightFadeEnabled)
			return;
		final int alpha = (int) (mRightFadeDegree * 255 * Math
				.abs(1 - openPercent));
		mRightFadePaint.setColor(Color.argb(alpha, 0, 0, 0));
		int left = mContent.getRight();
		int right = mContent.getRight() + getCardWidth();
		canvas.drawRect(left, 0, right, getHeight(), mRightFadePaint);
	}

	private void drawFade(Canvas canvas) {
		// if (mSlidingMode == SLIDINGMODE_LEFT) {
		// drawLeftFade(canvas, getPercentOpen());
		// } else if (mSlidingMode == SLIDINGMODE_RIGHT) {
		// drawRightFade(canvas, getPercentOpen());
		// } else if (mSlidingMode == SLIDINGMODE_LEFT_RIGHT) {
		// drawLeftFade(canvas, getPercentOpen());
		// drawRightFade(canvas, getPercentOpen());
		// }
	}

	// private void drawDim(Canvas canvas, float openPercent) {
	// final int alpha = (int) (0.6f * 255 * openPercent);
	// mDimPaint.setColor(Color.argb(alpha, 0, 0, 0));
	// int left = mContent.getLeft();
	// int right = mContent.getRight();
	// int top = mContent.getTop();
	// int bottom = mContent.getBottom();
	// canvas.drawRect(left, top, right, bottom, mDimPaint);
	// }

	protected boolean isLeftOpen() {
		return mScrollX < 0;
	}

	protected boolean isRightOpen() {
		return mScrollX > 0;
	}

	protected float getPercentOpen() {
		return Math.abs(mScrollX - mContent.getLeft()) / getCardWidth();
	}

	@Override
	protected void dispatchDraw(Canvas canvas) {
		final int count = getChildCount();
		for (int i = 0; i < count; i++) {
			final View child = getChildAt(i);
			if (child == null)
				return;
		}
		super.dispatchDraw(canvas);
		if (mScrollState != SCROLL_STATE_IDLE) {
			drawFade(canvas);
			drawShadow(canvas);
		}
	}

	private boolean isLowQuality = false;

	public void setLowQuality(boolean lowQuality) {
		isLowQuality = lowQuality;
	}

	private void disableLayers() {
		ViewCompat.setLayerType(this, ViewCompat.LAYER_TYPE_NONE, null);
		final int childCount = getChildCount();
		for (int i = 0; i < childCount; i++) {
			ViewCompat.setLayerType(getChildAt(i), ViewCompat.LAYER_TYPE_NONE,
					null);
		}
	}

	public OrderEvaluationActivity2 getOrderEvaluationActivity() {
		return mOrderEvaluationActivity2;
	}

	public void setOrderEvaluationActivity2(
			OrderEvaluationActivity2 mOrderEvaluationActivity2) {
		this.mOrderEvaluationActivity2 = mOrderEvaluationActivity2;
	}

	public String getOrderId() {
		return order_id;
	}

	/**
	 * 设置订单id order_id
	 */
	public void setOrderId(String order_id) {
		this.order_id = order_id;
		initCardChildView();
	}

	/**
	 * 设置支付Id pay_id
	 */
	public void setPayId(int pay_id) {
		this.pay_id = pay_id;
	}

	public int getPayId() {
		return pay_id;
	}

	public void setMyOrderList(MyOrderList mMyOrderList) {
		this.mMyOrderList = mMyOrderList;
	}

	public MyOrderList getMyOrderList() {
		return mMyOrderList;
	}

	public void setCurrentStatus(int ym_status) {
		this.ym_status = ym_status;
	}

	public int getCurrentStatus() {
		return ym_status;
	}

	public void setLoadSuccess(boolean isSuccess) {
		this.isSuccess = isSuccess;
	}

	public boolean getLoadSuccess() {
		return isSuccess;
	}
	/**
	 * 设置是线上还是线下
	 */
	public void setisLine(int isLine) {
		this.isLine = isLine;
	}

	public void setUserImageShady(float offset, int feelType) {
		if (offset >= 1) {
			offset = 0;
		}
		if (feelType == DiscoverContainerView.TYPE_HEARTBEAT) {
		} else {
		}
		float imageAlpha = 0;
		if (offset > 0) {
			imageAlpha = 0.5f + offset;
			if (imageAlpha > 1f) {
				imageAlpha = 1;
			}
		}
		headShadyImageView.setAlpha((int) (255 * imageAlpha));
		Drawable drawable = headShadyImageView.getBackground();
		if (drawable != null) {
			int bgAlpha = (int) (255 * offset);
			if (bgAlpha > 0 && bgAlpha < 160) {
				bgAlpha = 40 + bgAlpha;
			}
			drawable.setAlpha(bgAlpha);
		}
	}

	public OnClickListener operatClick = new OnClickListener() {

		@Override
		public void onClick(View v) {
			switch (v.getId()) {
			// case R.id.feel_imageview:
			// arrowScroll(FOCUS_LEFT);
			// break;
			// case R.id.nofeel_imageview:
			// arrowScroll(FOCUS_RIGHT);
			// break;
			default:
				break;
			}
		}
	};

	public View getContentView() {
		return contentView;
	}

	@Override
	public void onClick(final View v) {
		switch (v.getId()) {
		case R.id.btn_coupon:
			getOrderEvaluationActivity().mSharePopView.onShow(btn_coupon,Value.TYPE_SHARE,order_id,DateFormat.onDate_Long(mMyOrderList.getOrder_time()));
			break;
		case R.id.ib_sj:
			// 用intent启动拨打电话
			context.startActivity(new Intent(Intent.ACTION_DIAL, Uri
					.parse("tel:"
							+ mMyOrderList.getDriver_phone())));
		}
	}
    public int isLine=PriceDetail.INT_NOLINE;;//判断是线上还是线下，1为线上，2为线下
	/**
	 * 设置我要优惠劵按钮的显示或隐藏
	 */
	public void setBtnCouponVisibility(boolean IsVisibility) {
		if (IsVisibility&&getOrderEvaluationActivity().coupon_switch==ShareDetail.STATUS_OPEN
				&&(getOrderEvaluationActivity().coupon_switch2&isLine)>0) {
			btn_coupon.setVisibility(View.VISIBLE);
		} else {
			btn_coupon.setVisibility(View.GONE);
		}
	}


	/**
	 * @param isSuccess
	 * 支付完成
	 */
	public void onPayFinish(boolean isSuccess) {
		//处理下当前页面的
		getOrderDetail(order_id, false);
		if (isSuccess) {
			Msgs.Data msgs_data = null;
			if (OrderEvaluationActivity2.jmsg_data != null && !OrderEvaluationActivity2.jmsg_data.equals("")) {
				msgs_data = (Msgs.Data) new JsonBuild().getData(
						Msgs.Data.class, OrderEvaluationActivity2.jmsg_data.toString());
			}
			if (getYMStatus() == STATUS_PAY) {
				if (msgs_data != null) {
					getOrderEvaluationActivity().onNotify(GMsg.ONLINE_FINISH, null, msgs_data);
				} else {
					tv_confirm.setText(R.string.btn_confirmation);
				}
			}
		}
     }
	/**
	 * 支付成功
	 */
	public void onPaySuccuss() {
		isPaySuccuss=true;
		if(getYMStatus() != STATUS_EVA){
		new Handler().postDelayed(new Runnable() {

			@Override
			public void run() {
				setYMStatus(STATUS_EVA);
				mMyOrderList.setOrder_status(Value.ORDER_STATUS_FINISH);
				db_myorder.onUpdate(mMyOrderList);
				MyOrderingDB db_myordering = new MyOrderingDB();
				db_myordering.onDelete(context, order_id);
				getOrderDetail(order_id, true);
			}
		}, 300);
		}
	}
	/**
	 * 爱心活动
	 */
	public void onAixinActivity(){
		//爱心直通车隐藏
		if(mMyOrderList.getOrder_origin()==Value.ORDER_ORIGIN&&
				tv_confirm.getText().toString().equals(context.getString(R.string.agin_xiadan))) {
			layout_confirm.setVisibility(View.GONE);
			getOrderEvaluationActivity().tv_right.setVisibility(View.GONE);
			layout_hint_paytype.setVisibility(View.GONE);
		}else{
			layout_confirm.setVisibility(View.VISIBLE);
			if(mMyOrderList.getOrder_origin()!=Value.ORDER_ORIGIN){
				getOrderEvaluationActivity().tv_right.setVisibility(View.VISIBLE);
			}else{
				getOrderEvaluationActivity().tv_right.setVisibility(View.VISIBLE);
			}
			layout_hint_paytype.setVisibility(View.VISIBLE);
		}
	}
}
